C# – Parameter is less accessible than method

clist

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]);
            branchOverview.Show();
        }
        else
        {
            // Branch doesn't exist for some reason
        }
    }
}

And then in my BranchOverview class:

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

public BranchOverview(List<Branch> myArgus)
{
    InitializeComponent();

    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>)'

Best Answer

You have to declare Branch to be public:

public class Branch {
  . . . 
}
Related Topic