Thursday, July 10, 2008

How to create random numbers in c#?

This code show, how to Generate two random numbers , and return the number as a string value.
Public string getrandomnumber(string startnum,string Endnum)
DateTime tmeNow = DateTime.Now;
int Millisecond= tmeNow.Millisecond;
Random rndNumber = new Random(Millisecond);
int num1= rndNumber.Next(Tools.getInt(startnum), Tools.getInt(Endnum));
int num2= rndNumber.Next(Tools.getInt(startnum), Tools.getInt(Endnum));

Create an item number from the random numbers
return NewNumber1.ToString() + NewNumber2.ToString();

No comments: