Archive

Archive for September 26, 2008

How to generate Random numbers in .NET

September 26, 2008 Imran Akram 3 comments

Actually these are not exactly ‘true’ random numbers. These are actually pseudo-random numbers, which means that they give you an illusion that they’re being generated randomly.

It’s very simple: There’s a class called System.Random. and the rest is as simple as this:-

Random r = new Random(0);
int num = r.Next(0,999999);

in VB .NET

dim r as Random = new Random(0)
dim num as Int = r.Next(0,999999)