I am trying to code a random generator using a list in the code behind. I am able to get a fully working number generator using the code below but I now want the generator to run through a list of places and not numbers but I'm stuck with it as I am completely new to developing.
Code for random number generator
private void btnGenerate_Click(object sender, EventArgs e)
{
Random Place = new Random();
int Places = Place.Next();
txtResult.Text = Places.ToString();
}
As I said I want my generator to use places to eat (for example) but I am stuck
private void btnGenerate_Click(object sender, EventArgs e)
{
Eat = new List<string>();
Eat.Add("Tesco");
Eat.Add("KFC");
Eat.Add("Subway");
Eat.Add("Chippy");
Random Place = new Random();
int Places = Place.Next();
txtResult.Text = Places.ToString();
}
I tired commenting out the int Places = Place.Next(); and changing txtResult.Text = Places.ToString(); to txtResult.Text = Eat.ToString(); but this causes the following error to display in the field on my application when I click the 'Generate' button
System.Collections.Generic.List`1[System.String]