Quote:
Originally Posted by Alias
You want to fill an array with a length of fourty-two, with numbers one to fourty-two and further yet the numbers should be at random points in the array, right?
If I got that right, why not just fill the array with values one through to fourty-two and manually shuffle the array?
|
Indeed this is a good way of looking at doing this, it would sure that you do notn have duplicates, and you could simple use a random number to access different slots of the array. Using the same technique to ensure that you do not choose the same slot.
But working with what you have, you may find that the reason you have a 0 at the end is simple you have declared and array of size 43 instead of 42, not sure on that but quite often that is the reason behind it.
Alias, just added a method Using ArrayLists or Vectors, not sure if C# uses arraylists im sure he will clarify which it is, which does indeed make things simpler for you.
Chris