I am attempting to shuffle an array, but the way I am doing it only works about every fifth time. I would greatly appreciate if someone could explain why it is not working properly and perhaps propose a tweak.
private Button[] scrambleBoard(Button[] buttons)
{
for (int x = 100 * buttons.Count(); x > 0; x--)
{
Random rand = new Random();
int first = rand.Next(buttons.Count());
int second = rand.Next(buttons.Count());
Button temp = buttons[first];
buttons[first] = buttons[second];
buttons[second] = temp;
}
return buttons;
}