.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Generate Random Number at runtime

Posted By:Praveen       Posted Date: December 08, 2008    Points: 10    Category: Collections    URL: http://www.dotnetspark.com  

This code is useful to Generate Random number in C# at runtime, .NET Framework provide Random class to generate random number at runtime. Random class is present under System Namespace.

Random random = new Random();

int randomNumber = random.Next();// any random integer value

int anotherRandomNumber = random.Next(5, 100);// this will generate random number greater than 5 and less then 100.

int anotherRandomNumber1 = random.Next(100);// this will generate random number less then 100.

Happy Coding


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend