Parameter is less accessible than method

后端 未结 5 1984
既然无缘
既然无缘 2021-01-04 05:21

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

List myArgus = new List();

private void btnLogin_Cl         


        
相关标签:
5条回答
  • 2021-01-04 05:48

    You have to declare Branch to be public:

    public class Branch {
      . . . 
    }
    
    0 讨论(0)
  • 2021-01-04 05:49

    As the error message says, the type of all parameters of a method must be at least as accessible as the method itself.

    You need to make your Branch class public if you are using it as a parameter in a public method.

    public class Branch { .... } 
    ^^^^^^
    

    Alternatively you could change your method to be internal instead of public.

    internal BranchOverview(List<Branch> myArgus)
    ^^^^^^^^
    
    0 讨论(0)
  • 2021-01-04 05:51

    By default, fields of a class are private if no access modifier is present ...

    0 讨论(0)
  • 2021-01-04 06:03

    Change:

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

    to be public.

    0 讨论(0)
  • 2021-01-04 06:06

    The constructor of BranchOverview is public, which means that all types involved in its formal parameter list must also be public. Most probably you have not provided an accessibility specification for Branch, i.e. you have written

    class Branch { ... }
    

    which means that Branch is internal.

    0 讨论(0)
提交回复
热议问题