I have question about assigning value to the list<> member of another object. I'm receiving error saying that the list<> member is NULL reference. It seems that i have to instantiate the list<> member?
public class Person
{
public string FirstName {set;get:}
public string LastName {set;get;}
public string Country {set;get;
public List<string> Hobbies;
}
public class Survey
{
public List<Person> Poll;
public void StartPoll()
{
Person p = new Person();
p.FullName = "Billy";
p.LastName = "Bob";
p.Location = "America";
p.Hobbies.Add("Hiker");// this is where error occurs
p.Hobbies.Add("Musician");// this is where error occurs
Poll = new List<Person>();
Poll.Add(p);
}
}