for (int i = 1; i <= 55; i++ )
{
System.Random myRandom = new System.Random();
//int myInt; 3 lines just alternate method
//myInt = myRandom.Next();
//System.Console.WriteLine(myInt);
System.Console.WriteLine(myRandom.Next());
Thread.Sleep(15); // if less, trouble
}
I kept getting multiples of the same number, up to twenty at a time, instead of each consecutive number being different. For some reason I added the sleep statement and it works if the value is 15 or greater. In fact, if you increment the sleep argument value, you can 'select' how many consecutive repeated numbers you get. Setting a range made no difference. Is the loop faster than the random number generator? This is not serious, I am working through the book "Essential C# 5.0". I looked at least fifty "random" questions, but none covered this phenomena. The three commented lines are a different way to do the same thing, I did not execute both in the same build.