Reputation: 63
I've got a list in a class that I'm trying to return to view on a form but I cant return it from the class, How would I do this?
On the class:
private List<Module> modules;
public void AddModule(Module add)
{
modules.Add(add);
}
public List Modules
{
get { return modules; }
}
On the form:
moduleTitleLabel.Text = cnet.Title;
stgOne.AddModule(cnet);
moduleList.DataSource = stgOne.Modules;
I get an error on the List on the return.
Upvotes: 0
Views: 3010
Reputation: 28747
Your datatypes are different:
private List<Module> modules;
public void AddModule(Module add)
{
modules.Add(add);
}
// this one should be generic too
public List<Module> Modules
{
get { return modules; }
}
Upvotes: 2
Reputation: 27614
You're missing generic type argument, it should be:
public List<Module> Modules
{
get { return modules; }
}
Upvotes: 1