Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameter is less accessible than method

Tags:

c#

list

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>)'
like image 792
James Dawson Avatar asked Mar 15 '12 19:03

James Dawson


People also ask

How do you fix inconsistent accessibility in C#?

You can fix it by making the base class the same access level as the derived class, or restricting the derived class.

What is less accessible?

1 without; lacking. speechless. 2 not able to (do something) or not able to be (done, performed, etc.) countless.


1 Answers

You have to declare Branch to be public:

public class Branch {
  . . . 
}
like image 192
MiMo Avatar answered Sep 30 '22 19:09

MiMo