Example

using System;

namespace Samples
{
  public class RandomSample
  {
    public static void Main()
    {
      Random r = new Random();
      DisplayNumbers(r, 4);
      r = new Random();
      DisplayNumbers(r, 4);
      r = new Random(unchecked(
                       (int)DateTime.Now.Ticks));
      DisplayNumbers(r, 4);
      Byte[] bytes = new Byte[4];
      r.NextBytes(bytes);
      Console.WriteLine("Bytes");
      foreach(Byte b in bytes)
        Console.Write("{0} ", b);
      Console.WriteLine();
    }
    public static void DisplayNumbers(Random r, int number)
    {
      Console.WriteLine("Integers");
      for(int i = 0; i < number; i++)
        Console.Write("{0} ", r.Next());
      Console.WriteLine();
      Console.WriteLine("Doubles");
      for(int i = 0; i < number; i++)
        Console.Write("{0} ", r.NextDouble());
      Console.WriteLine();
    }
  }
}
The output is
 Integers 610101060 182710372 ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.