You need to add an instance of the class:
lstemail.Add(new EmailData { FirstName = "John", LastName = "Smith", Location = "Los Angeles"});
I would recommend adding a constructor to your class, however:
public class EmailData
{
public EmailData(string firstName, string lastName, string location)
{
this.FirstName = firstName;
this.LastName = lastName;
this.Location = location;
}
public string FirstName{ set; get; }
public string LastName { set; get; }
public string Location{ set; get; }
}
This would allow you to write the addition to your list using the constructor:
lstemail.Add(new EmailData("John", "Smith", "Los Angeles"));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…