Random class namespace:
System. Object
System. Random
A pseudo-random number generator, a device that can generate digital sequences that meet certain random statistical requirements.
Remarks
A pseudo-random number is selected from a finite number with the same probability. The selected numbers are not completely random because they use a definite math.AlgorithmBut from a practical point of view, the degree of randomness is enough.
The random number is generated starting from the seed value. If the same seed is used repeatedly, the same digital series is generated. One way to generate different sequences is to associate the seed values with time, so that different generations are generated for each new instance of random.
To improve performance, create a random so that many random numbers can be generated over time, instead of repeatedly creating a new random to generate a random number.
Method
1: Next
The reload list returns a non-negative random number.
[Visual Basic] overloads public overridable function next () as integer
[C #] Public Virtual int next ();
Returns a nonnegative random number that is less than the specified maximum value.
[Visual Basic] overloads public overridable function next (integer) as integer
[C #] Public Virtual int next (INT );
Returns a random number within the specified range.
[Visual Basic] overloads public overridable function next (integer, integer) as integer
[C #] Public Virtual int next (INT, INT );
2: nextdouble
Returns a random number between 0.0 and 1.0.
[Visual Basic] public overridable function nextdouble () as double
[C #] Public Virtual double nextdouble ();
3: nextbytes
Fill in the elements of the specified byte array with a random number.
Example:
Random RND = new random ();
Byte [] B = new byte [10];
RND. nextbytes (B );
Console. writeline ("the random bytes are :");
For (INT I = 0; I <10; I ++ ){
Console. Write (I );
Console. Write (":");
Console. writeline (B [I]);
}
this article from the csdn blog, reprinted please indicate the source: http://blog.csdn.net/johnsonTj/articles/317712.aspx