I'm fairly new to programming (started a few days ago), and I decided to make a random number generator. The problem I have, is that I can't generate an extremely large number. I searched around, and read that I could change 'int' to 'long', but I am having troubles when it comes to the random number generator.
Here's part of my code:
long min;
long max;
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("Minimum Number: ");
min = Convert.ToInt64(Console.ReadLine());
Console.Write("Maxinum Number: ");
max = Convert.ToInt64(Console.ReadLine());
if (max < min)
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("You must choose a larger number! Press any key to restart...\n");
Console.ReadKey(true);
Generator();
}
Random randomnumber = new Random();
while (true)
{
long randomnumout = randomnumber.Next(min, max + 1);
Console.ForegroundColor = ConsoleColor.White;
int randomsleep = randomnumber.Next(250, 750);
Console.WriteLine("\nGenerating...");
Thread.Sleep(randomsleep);
}
In visual studio,
randomnumber.Next(min, max + 1)
is underlined
The errors:
Error 2 Argument 1: cannot convert from 'long' to 'int'
Error 3 Argument 2: cannot convert from 'long' to 'int'
Error 1 The best overloaded method match for 'System.Random.Next(int, int)' has some invalid arguments
I've searched around online, and am still confused.