http://pastebin.com/VhfXQQAr
What happens is, the number DOES get randomly generated, but will print off the same number 4 times. I want a random one 4 times.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
daniel noPosted Nov 6, 2012, 9:35 AM
VulpesPosted Nov 6, 2012, 9:27 AM
Try it like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
private static Random rnd = new Random(); // moved here
static void Main()
{
turn();
Console.Read();
}
static int DiceThrow()
{
int rolled = rnd.Next(1, 7); //random number from 1 to 6
return rolled;
// return int.Parse(Console.ReadLine());
}
private static void turn()
{
for (int i = 0; i < 4; i++)
{
int numrolled = DiceThrow();
Console.WriteLine(numrolled);
}
}
}
}