摘要:產生亂數ArrayList
//input: 開始數字、結束數字、產生數量
protected ArrayList GenerateRandom(int start, int end, int count)
{
if (start > end)
throw new ArgumentException();
if (count > end - start + 1)
throw new ArgumentException();
ArrayList randomValues = new ArrayList();
Random rm = new Random ();
int randomValue;
for (int idx = 0; idx < count; ++idx)
{
do
{
randomValue = rm.Next(start, end+1);
} while (randomValues.Contains(randomValue));
randomValues.Add(randomValue);
}
return randomValues;
}