public List<int> CalculateRandom(int maxValue,int num)
{
List<int> result = new List<int>();
Random ran = new Random();
bool isOK = false;
while (!isOK)
{
int key = ran.Next(0, maxValue);// 取最大值
if (!result.Contains(key))
{
result.Add(key);
if (result.Count == num)// 获得了需要的数量
{
isOK = true;
}
}
}
return result;
}