ADO.NET生成100个1-100之间的不重复的随机数
public static void funrandom()
{Random rand = new Random();
ArrayList arraylist = new ArrayList();
for (int i = 0; i < 100; i++)
{
arraylist.Add(i + 1);
}
ArrayList arraylist1 = new ArrayList();
for (int i = 100; i >0; i--)
{
int n = rand.Next(1, i);
arraylist1.Add(arraylist[n - 1]);
arraylist.Remove(arraylist[n - 1]);
}
string s = "";
foreach (int a in arraylist1)
{
s += a.ToString()+",";
}
Console.WriteLine(s.TrimEnd(','));
Console.Read();
}