Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
can any one ans....



how to generate a no starting from 123



my coding.....




C#
public void publickey()
   {
       Random rand = new Random((int)DateTime.Now.Ticks);
       int numIterations = 0;
       numIterations = rand.Next(6745, 9876);
       Label5.Text = numIterations.ToString();

   }
Posted
Comments
psgviscom 18-Feb-12 2:10am    
Not clear
Nilesh Patil Kolhapur 18-Feb-12 2:42am    
do u want random no or what?
krumia 20-Feb-12 5:07am    
Not clear... Are you trying to get random numbers that are bigger than 123... or do you want to get numbers such as 1236, 12396, 1238, 123958, 123*, ...?

1 solution

the two parameters in the rand.Next method yuo are using specify the minumum and maximum random numbers to be returned - so if you need a number from 123 up, then use

numIterations = rand.next(123, 999);


which will provide a random number between 123 and 999
 
Share this answer
 
Comments
Tech Code Freak 18-Feb-12 3:29am    
5up!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900