Random Number Generator in C#

In C#, you can use the Random class to generate random numbers. Here's a simple example that generates a random integer between 1 and 10, inclusive:

            using System;

            class Program
                    static void Main()
                        Random rnd = new Random();  // Create a new Random object
                        int randomNumber = rnd.Next(1, 11);  // Generate a random number between 1 and 10

                        Console.WriteLine($"Random Number: {randomNumber}");  // Print the random number


In this code:

Preset number shortcuts between

Digit shortcuts

Code samples