Shifted and scaled random integers. - CSharp Language Basics

CSharp examples for Language Basics:Random

Description

Shifted and scaled random integers.

Demo Code

using System;//from   ww w .ja v  a2s.c om
class MainClass
{
   static void Main()
   {
      Random randomNumbers = new Random(); // random-number generator
      for (int counter = 1; counter <= 20; ++counter)
      {
         // pick random integer from 1 to 6
         int face = randomNumbers.Next(1, 7);
         Console.Write($"{face}  "); // display generated value
      }
   }
}

Result


Related Tutorials