generate multiple random numbers from an array in c# code example
Example 1: c# two different random numbers
Random random = new Random();
int randomNumber1 = random.Next(0, 300);
int randomNumber2 = random.Next(0, 300);
//...
Example 2: how to generate random unique id in c#
public Random a = new Random(); // replace from new Random(DateTime.Now.Ticks.GetHashCode());
// Since similar code is done in default constructor internally
public List<int> randomList = new List<int>();
int MyNumber = 0;
private void NewNumber()
{
MyNumber = a.Next(0, 10);
while(randomList.Contains(MyNumber))
MyNumber = a.Next(0, 10);
}