James Dawson James Dawson - 1 year ago 123
C# Question

Parameter is less accessible than method

I'm trying to pass a list from one form class to another. Here's the code:

List<Branch> myArgus = new List<Branch>();

private void btnLogin_Click(object sender, EventArgs e)
// Get the selected branch name
string selectedBranch = lbBranches.SelectedItem.ToString();
for (int i = 0; i < myArgus.Count; i++)
if (myArgus[i]._branchName == selectedBranch)
// Open the BranchOverview form
BranchOverview branchOverview = new BranchOverview(myArgus[i]);
// Branch doesn't exist for some reason

And then in my

List<Branch> branch = new List<Branch>();

public BranchOverview(List<Branch> myArgus)

branch = myArgus;

When I run the code, I get this error:

Inconsistent accessibility: parameter type 'System.Collections.Generic.List<Argus.Branch>' is less accessible than method 'Argus.BranchOverview.BranchOverview(System.Collections.Generic.List<Argus.Branch>)'

Answer Source

You have to declare Branch to be public:

public class Branch {
  . . . 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download