C#生成不重复(随机数 http://www.jbxue.com/tags/suijishu.html)列表实例的代码。
例子:
例子:
/// <summary>
/// 生成不重复随机数列表实例
/// </summary>
/// <param name="count">不重复数数量</param>
/// <returns>不重复数列表</returns>
private static List<int> GetRandomList(int count)
{
List<int> list = new List<int>();
int num = ;
Random rnd = new Random();
for (int i = ; i < count; i++)
{
do
{
num = rnd.Next(, );
} while (list.Contains(num));//
list.Add(num);
}
return list;
}