```
/// <summary>
/// method for generating a certain amount of random numbers
/// The user provides how many random numbers to generate, and the
/// minimum and maximum values the randon numbers can be
/// </summary>
/// <param name="min">minimum value</param>
/// <param name="max">maximum value</param>
/// <param name="howMany">how many random numbers the user wants</param>
/// <returns></returns>
private static List<int> GenerateRandomNumbers(int minValue, int maxValue, int howMany)
{
//create a generic list of integers
List<int> numberList = new List<int>();
//create an instance of the random class
Random rand = new Random();
//a loop for how many random numbers the user wants
for (int i = 0; i < howMany; i++)
{
int value = rand.Next(minValue, maxValue);
//check and make sure the current
//random number does not exist in our list
if(!(numberList.Contains(value)))
{
//since it doesnt already exist in our list
//we can add it to our list
numberList.Add(value);
}
}
return numberList;
}
```

**Are you able to help answer this sponsored question?**

Questions asked by members who have earned a lot of community kudos are featured in order to give back and encourage quality replies.

Recommended Topics