C# Random

Random class can be used to generate random number.

using System.Random;
Random r = new Random();

You can specify a integar as random seed:
int sd = 12;
Random r = new Random(sd);

Get a random number between 0 and 2,147,483,647:
r.Next();

Get a random number between 0 and a specified number:
r.Next(100);

Get a random number between two specified numbers:
r.Next(10,100); //a radndom number between 10 - 100
r.Next(100,1000); //a radndom number between 100 - 1000



endmemo.com © 2024  | Terms of Use | Privacy | Home