HighTechTalks DotNet Forums  

How to Shuffle array of chars

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss How to Shuffle array of chars in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ruski
 
Posts: n/a

Default 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);
}
}

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.