Friday, March 7, 2014

Random Class

Click Here - Array Class , String Class , Math Class , Random Class

Random Class

Library: System.Random
This 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:
           Random r = new Random();
  • Generate the random number based on the given boundary values:
           r.Next(min value, max value);

 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();
}
}
}

Download above code for Demo of Random Class : Download Links


Click Here - Array Class , String Class , Math Class , Random Class

No comments:

Post a Comment

Flag Counter