How to scramble string C#?
Posted
by
a_Elnajjar
on Stack Overflow
See other posts from Stack Overflow
or by a_Elnajjar
Published on 2012-11-12T04:54:31Z
Indexed on
2012/11/12
4:59 UTC
Read the original article
Hit count: 119
I write the code to scramble word I am create simple game jumble
string jumble = theWord;
int length = jumble.Count();
for (int i = 0; i < length; ++i)
{
int index1 = (rand.Next() % length);
int index2 = (rand.Next() % length);
char temp =jumble[index1];
jumble = jumble.Replace(jumble[index1], jumble[index2]);
jumble = jumble.Replace(jumble[index1], temp);
}
© Stack Overflow or respective owner