You need to instantiate the Lists in your AddedContacts
class’s constructor:
public class AddedContacts
{
private List<CreateContact> Contact;
public List<CreateContact> ClassCreateContact
{
get { return Contact; }
set { this.Contact = value; }
}
public AddedContacts()
{
Contact = new List<CreateContact>();
ClassCreateContact = new List<CreateContact>();
}
}
You also need to create an instance of AddedContacts
to work with and finally you need to watch case: It is Add
not add
:
AddedContacts AC = new AddedContacts();
AC.ClassCreateContact.Add(p);
2
solved C# How to add to list class?