Display random number in c#
Again a small tip, How to display n digit random numbers in ASP.NET using c# ? Its a bit simple you need to call Random class to generate numbers with minimum and maximum limits of digits (numbers).
the code is as Follow:
Code Snippet
- protected void Page_Load(object sender, EventArgs e)
- {
- int ranid = RandomNumber(10000, 99999);// can pass minium and maximum number for random number generation.
- Label1.Text = ranid.ToString();
- }
- private int RandomNumber(int min, int max)
- {
- Random random = new Random();
- return random.Next(min, max);
- }
A small tip but may be helpful for new ones……
Thanks….