I have a program in C# that needs to sort 12 names into 3 groups of 4, six times, and dump them into a CSV file. It uses a textbox
for user input to be put into an array and displayed in a datagrid
. Then the program reads the names and puts them into a CSV file and also displays them into another datagrid
. The code below only does the 3 groups of 4 once, and they are in the order that the user enters. How do I get 5 more groups of random (or at least somewhat random) names in 3 groups of 4?
public void des()
{
for (int x = 0; x < 7; x++)
{
//for (int o = 0; o < desArayPlayers.Length; o++)
{
int playersCount = 0;
int k = 0;
for (int i = 1; i < 4; i++)
{
switch (i)
{
case 1:
k = 0;
break;
case 2:
k = 4;
break;
case 3:
k = 8;
break;
default:
break;
}
for (int j = k; j < k + 4; j++)
{
sortingGroupsArayPlayers[playersCount] = "Group " + i.ToString() + " " + arayPlayers[j];
//MessageBox.Show(desArayPlayers[playersCount]);
playersCount++;
}
}
}
}
}