• Top Posts

    How to generate a random number in C#


    • By using the following example we can generate the random number.
    • Result of the program by every time changes because of  these are random numbers. 
    • Random class is used to generate random numbers.



      class RandomNumber  
       {  
         public static void Main(string[] args)  
         {  
           Random r = new Random();  
           int n = r.Next();  
           Console.WriteLine(n);  
           Console.ReadLine();  
         }  
        }  
    

    No comments

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728