static Random r = new Random();
public static int Randfunc(int start, int end)
{
List<int> numbers = new List<int>();
int n = r.Next(start, end);
return n;
}
答案 0 :(得分:-1)
尝试类似的东西;
var start = 0;//Min range of numbers
var end = 1000;//Max range of numbers
int i = 0;
Random random = new Random();
var numbers = new HashSet<int>();
while(i < 100)//Collect 100 unique numbers
{
var number = random.Next(start, end);
if (!numbers.Contains(number))
{
numbers.Add(number);
i++;
}
}