c# - Problem in generating random number -
possible duplicate:
why appear random number generator isn't random in c#?
dear friends
i want generate 4 random number between 1 - 55 ,but problem of time receive 2 number same :( example generated number 2 2 5 9 or 11 11 22 22! dont know why? use :
random random = new random(); return random.next(min, max);
for generating random number. put them in while repeating 4 times. idea?would u me plz?
you should create 1 random() object , reuse instead of creating new 1 each random number generate.
the reason every time create new random object seeds current time. if create multiple random objects within short period of time then seed same time, , generate same numbers.
Comments
Post a Comment