C# Random Next()
Description
Random Next()
returns a nonnegative random integer.
Syntax
Random.Next()
has the following syntax.
public virtual int Next()
Returns
Random.Next()
method returns A 32-bit signed integer greater than or equal to zero and less than MaxValue.
Example
The following example generates random integers with various overloads of the Next method.
// w w w . j a v a2 s. co m
using System;
public class RandomNextDemo
{
static void Main( )
{
Random randObj = new Random( 1 );
// Generate six random integers from 0 to int.MaxValue.
for( int j = 0; j < 6; j++ )
Console.WriteLine( randObj.Next( ) );
}
}
The code above generates the following result.