I'm trying to make a random generator that selects a specific number of names from a list and pairs them together.
private void button1_Click(object sender, EventArgs e)
{
string[] lines = File.ReadAllLines(@"C:\Users\Brown\source\repos\Generator\bin\names.txt");
List<string> source = new List<string>();
int n = int.Parse(textBox1.Text);
for (int i = 0; i < n; i++)
{
source.Add(lines[new Random().Next(lines.Length)]);
}
string joinNames = string.Join(" x ", source);
genResult.Text = joinNames;
}
I got it to work but when i click the generate button I see duplicates of some names.