How to Shuffle array of chars
From: Ruski (Ruski_at_discussions.microsoft.com)
Date: 11/29/04
- Previous message: Ilya Potekhin: "IFilter & Stream"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 29 Nov 2004 13:09:02 -0800
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);
}
}
- Previous message: Ilya Potekhin: "IFilter & Stream"
- Messages sorted by: [ date ] [ thread ]