Random.Next() : Random « System « C# / C Sharp by API






Random.Next()

  
using System;

class CondOpApp {
    [STAThread]
    static void Main(string[] args) {
        Random rand = new Random();
        int a = 0, b = 0;

        for (int i = 0; i < 5; i++) {
            a = rand.Next() % 100;
            b = rand.Next() % 100;

            Console.WriteLine("a={0}, b={1}, so the winner is: {2}", a, b, a > b ? 'a' : 'b');
        }
    }
}

   
    
  








Related examples in the same category

1.Random.Next(range)
2.Random.NextDouble()