0

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.

0

2 Answers 2

2

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; }
}
Sign up to request clarification or add additional context in comments.

Comments

1

You're missing generic type argument, it should be:

public List<Module> Modules
{
    get { return modules; }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.