分类:
NET
c#产生不重复的随机数
public List<int> CreateRandom()
{
List<int> lotters = new List<int>();
Random random = new Random();
for (int i = 0; i < 6; i++)
{
int lotter = random.Next(1, 7);
if (lotters.Contains(lotter))//重复了抛弃这个数重新产生
{
i--;
continue;
}
lotters.Add(lotter);
}
return lotters;
}评价
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256
50010702506256
欢迎加群交流技术