Commit 5580a06f authored by caiwg's avatar caiwg

修复人员随机数生成最大值及返回格式问题

parent 4391dbdc
......@@ -48,7 +48,7 @@ namespace Lottery
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3936.0 Safari/537.36 Edg/79.0.301.2");
var resp = await httpClient.GetAsync($"https://www.random.org/integer-sets/?sets=1&num={length}&min=1&max={length}&commas=on&order=random&format=html&rnd=new");
var resp = await httpClient.GetAsync($"https://www.random.org/integer-sets/?sets=1&num={length}&min=0&max={length-1}&commas=on&order=random&format=plain&rnd=new");
if (resp.IsSuccessStatusCode)
{
string content = await resp.Content.ReadAsStringAsync();
......@@ -60,7 +60,8 @@ namespace Lottery
{
}
return null;
var r = new Random(length);
return Enumerable.Range(0, length).Select(p => r.Next(1, length + 1)).ToList();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment