Friday, July 17, 2009

Q: Why my C# Random generator always generates the same number?

That's because you're making the Random instance in the method, which causes it to return the same values when called in quick succession.(Ref from network)

Use

private static Random random = new Random((int)DateTime.Now.Ticks);


then use random.nextDouble() to get the random number.

No comments:

Post a Comment