I have two methods. In the first one I am adding items to a list called Persons. In the second I need to select a random item from the list (Persons) and return the name of the person from the list.
I'm unsure of how to do this. I've tried generating a random number and a random letter however I can't understand how to use these with the list.
Any help would be greatly appreciated! Thank you in advance
static void PopulatePersons()
{
Person Bill = new Person("Bill", "no", "brown", 'm');
Person Eric = new Person("Eric", "yes", "brown", 'm');
Person Robert = new Person("Robert", "no", "blue", 'm');
Person George = new Person("George", "yes", "brown", 'm');
Person Herman = new Person("Herman", "no", "green", 'm');
Person Anita = new Person("Anita", "no", "blue", 'f');
Person Maria = new Person("Maria", "yes", "green", 'f');
Person Susan = new Person("Susan", "no", "brown", 'f');
Person Claire = new Person("Claire", "yes", "brown", 'f');
Person Anne = new Person("Anne", "no", "brown", 'f');
Persons = new List<Person>()
{ Bill, Eric, Robert, George, Herman, Anita, Maria, Susan, Claire, Anne };
}
static Person GetRandomPerson()
{
PopulatePersons();
}