A
Arjen
Hi,
I have this string:
private string[] pairs = { "AB", "CD", "BD", "AC", "BC", "AD", "AB", "CD" };
Now I want to randomize all pairs, like the first AB to BA.
for (int i = 0; i < 8; i++)
{
string pair = pairs;
Random rnd1 = new Random();
Random rnd2 = new Random(rnd1.next(8)));
int result = rnd2.Next(2);
int second = 1;
if (result == 1)
{
second = 0;
}
Response.Write(pair[result] + " " + pair[second] + "<br />");
}
The problem is that I allways randomize the whole string. Thus if it AB
changed to BA, CD also will be DC.
What I want is 'true' randomization.
Can someone help?
Thanks!
Arjen
I have this string:
private string[] pairs = { "AB", "CD", "BD", "AC", "BC", "AD", "AB", "CD" };
Now I want to randomize all pairs, like the first AB to BA.
for (int i = 0; i < 8; i++)
{
string pair = pairs;
Random rnd1 = new Random();
Random rnd2 = new Random(rnd1.next(8)));
int result = rnd2.Next(2);
int second = 1;
if (result == 1)
{
second = 0;
}
Response.Write(pair[result] + " " + pair[second] + "<br />");
}
The problem is that I allways randomize the whole string. Thus if it AB
changed to BA, CD also will be DC.
What I want is 'true' randomization.
Can someone help?
Thanks!
Arjen