Hello i am having a problem with my code, i am attempting to create a sports fixture system where with a click of a button it generates "team vs team" at random
my problem is that i managed to randomize it but i am having trouble trying to cancel duplicates out (not necessarily remove them but make it so a team cannot play against itself and so shuffle each time)
here is my code :
for some extra context this "btnFixture" button is linked with two other textboxes so it can generate 2 separate the team separately if that is of any help.
public partial class Form2 : Form
{
string[] FirstTeam = { "Team 1" , "Team 2" , "Team 3" , "Team 4" };
string[] SecondTeam = { "Team 1", "Team 2", "Team 3", "Team 4" };
Random rand = new Random();
private void btnFixture_Click(object sender, EventArgs e)
{
int indexFirstTeam = rand.Next(FirstTeam.Length);
int indexSecondTeam = rand.Next(SecondTeam.Length);
this.txt1stTeam.Text = FirstTeam[indexFirstTeam];
this.txt2ndTeam.Text = SecondTeam[indexSecondTeam];
}
}
I really appreciate the help given in advance. thank you!