Possible Duplicates:
Why does it appear that my random number generator isn't random in C#?
Random number generator not working the way I had planned (C#)
Hello,
I use this function (in class) to randomize numbers:
private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
public void Init()
{
x = RandomNumber(0,500);
}
However if I later call multiple object to do it:
Obj[] obj = new Obj[64];
for( int i = 0 ; i < 64 ; i++ )
{
obj[i] = new Obj();
}
...
for( int i = 0 ; i < 64 ; i++ )
{
obj[i].Init();
}
then each object has exactly same 'x' value.
What is wrong here?