alex-md
9/22/2016 - 11:51 AM

Generate a Random Number in C#

Generate a Random Number in C#

using System;

public class numberGenerator
{
	public static void Main()
	{
		int minNumber;
		int maxNumber;
		Console.WriteLine("Please enter minimum value");
		minNumber = Convert.ToInt16(Console.ReadLine());
		Console.WriteLine("Please enter maximum value");
		maxNumber = Convert.ToInt16(Console.ReadLine());
		Random random = new Random();
		int randomNumber = random.Next(minNumber, maxNumber);
		Console.WriteLine("Your random number is {0}!", randomNumber);
	}
}