C# Random Random()
Description
Random Random()
initializes a new instance of the Random
class, using a time-dependent default seed value.
Syntax
Random.Random()
has the following syntax.
public Random()
Example
The following example uses the default constructor to instantiate three Random objects and displays a sequence of five random integers for each.
//from w w w .j a va 2s. c o m
using System;
using System.Threading;
public class RandomNumbers
{
public static void Main()
{
Random rand = new Random();
byte[] values = new byte[5];
rand.NextBytes(values);
foreach (byte value in values)
Console.Write("{0, 5}", value);
}
}
The code above generates the following result.