| 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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Mar 7, 2010, 8:41 PM EST
theLizardRank #1,079 · 1.8K reputationPosted Mar 7, 2010, 8:57 PM EST
George Loveless13 reputationPosted Mar 8, 2010, 5:54 AM EST
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.
George Loveless13 reputationPosted Mar 8, 2010, 7:03 AM EST
myCompany.myList = new List
myCompany.myList.Add(jim);
Sam HobbsRank #107 · 20.5K reputationPosted Mar 8, 2010, 11:12 AM EST
I did show in my reply that you need to instantiate the object. Please mark my response as the answer.