| Class Company { .. private list .. } .. ..// in main. Company myCompany = new Company(); myCompany.employees.add("jim"); // doesn't work myCompany.employees.add("sue"); // doesn't work |
Thank you much.
| Class Company { .. private list .. } .. ..// in main. Company myCompany = new Company(); myCompany.employees.add("jim"); // doesn't work myCompany.employees.add("sue"); // doesn't work |
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Mar 8, 2010, 4:12 PM
I did show in my reply that you need to instantiate the object. Please mark my response as the answer.
George LovelessPosted Mar 8, 2010, 12:03 PM
myCompany.myList = new List
myCompany.myList.Add(jim);
George LovelessPosted Mar 8, 2010, 10:54 AM
public class Person
{
public string fName;
public string lName;
}
public class Company
{
public List
}
public Window1()
{
InitializeComponent();
Person jim = new Person { fName = "jimmy", lName = "bridger" };
Company myCompany = new Company();
myCompany.myList.Add(jim); // stops here when stepping through..
}
It still isn't working do you guys have any ideas? I would prefer to keep "myList" as a property.
theLizardPosted Mar 8, 2010, 1:57 AM
Sam HobbsPosted Mar 8, 2010, 1:41 AM