Just to elaborate a bit on Dave's answer, you have committed a very common beginners' mistake.
When you instantiate a Random object (using the "new" keyword), that object is seeded with the current time such that every call to Next gives another number from a list of random numbers. If you instantiate a new Random object every time through a loop, as you have done, the loop will execute so fast that the seed will always be the same time (to the nearest millisecond or whatever the limit is) and hence the number that you get from the first call to Next on that object will always be the same. Thus you should instantiate the object only once, and keep calling Next on that object.
No comments:
Post a Comment