Random Class
Library: System.RandomThis class is used to generate a random number, at any time. In future, while performing different programming logics, this random number generation concept may be required.
Implementation:
- Create an instance:
- Generate the random number based on the given boundary values:
Program for Random Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RandomDemo
{
class Program
{
static void Main(string[] args)
{
Random r = new Random();
for (int i = 0; i < 300; i++)
{
Console.Write(r.Next(1, 300) + ", ");
}
Console.Read();
}
}
}
No comments:
Post a Comment