📜  在c#代码示例中生成一个随机数

📅  最后修改于: 2022-03-11 14:49:14.034000             🧑  作者: Mango

代码示例6
Random numberGen = new Random();
int amountToOutput = 4;
int minimumRange = 1;
int maximumRange = 20;

for(int i = 0; i < amountToOutput; i++)
{
  int randomNumber = numberGen.Next(minimumRange, maximumRange);
  Console.WriteLine(randomNumber);
}