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>)'
You can fix it by making the base class the same access level as the derived class, or restricting the derived class.
1 without; lacking. speechless. 2 not able to (do something) or not able to be (done, performed, etc.) countless.
You have to declare Branch
to be public:
public class Branch {
. . .
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With