How to Shuffle array of chars -
11-29-2004
, 04:09 PM
Hi all, is there any other way to shuffle array of chars. (E.g. less code,
more efficient) Then the one bellow. Thanks.
private static void Shuffle(char[] abc)
{
Random rd = new Random((int)DateTime.Now.Ticks);
for (int i = 0; i < 26; i++)
{
int index = 0;
do
{
index = rd.Next(0, 26);
} while (abc[index] != 0);
abc[index] = Convert.ToChar('a' + i);
}
} |