Please see:
https://msdn.microsoft.com/en-us/library/system.random%28v=vs.110%29.aspx[
^].
Don't make a common mistake, creating the instance of
System.Random
several times. Remember, the algorithm
pseudo-randon. To randomize of, always use the
seed:
https://msdn.microsoft.com/en-us/library/ctssatww%28v=vs.110%29.aspx[
^].
As you can see from the code sample shown in the article referenced above, you can use
System.DateTime.Now
for seeding. To understand why seeding is needed and how pseudo-random algorithm gives you random numbers, please see:
https://en.wikipedia.org/wiki/Pseudorandom_number_generator[
^].
After you create your instance of
System.Random
, reuse it for all your needs, just one instance. In your case, all other calls should be to
System.Random(int, int)
:
https://msdn.microsoft.com/en-us/library/2dx6wyd4(v=vs.110).aspx[
^].
[EDIT]
Warning! The parameter names are really misleading.
minValue
is really the minimum, but
maxValue
is not really maximum; the documentation calls it "exclusive upper bound", which means that real maximum is
maxValue − 1
. :-)
See also the notes in
Return value section.
[END EDIT]
Your "without loops" is simply an absurd. Okay, code the calls to
Random.Next
100 times to get 100 numbers, but I doubt anyone would be so insane.
—SA