dimanche 5 avril 2015

Random function refresh


Console.WriteLine("How many times would you like to roll?");
string count = Console.ReadLine();
int cnt = Convert.ToInt32(count);

for (int i = 1; i <= cnt; i++)
{
int rol = new int();
Random roll = new Random();
rol = roll.Next(1, 6);
Console.WriteLine("Die {0} landed on {1}.", i, rol);
}

Console.ReadLine();


I am trying to create a dice-rolling simulator in C#, but I'm encountering one problem: The random number never changes after the first roll. What is happening and how can I fix it?





Aucun commentaire:

Enregistrer un commentaire