Inaccessible due to its protection level?

前端 未结 5 575
臣服心动
臣服心动 2020-12-21 05:39

I\'m still quite new to coding in general, and while this simple program is only meant to be a test to learn how constructors work, I\'d still like to know why I\'m getting

5条回答
  •  眼角桃花
    2020-12-21 06:28

    Access modifiers are keywords used to specify the declared accessibility of a member or a type. This section introduces the four access modifiers:

    The following five accessibility levels can be specified using the access modifiers:

    1. public : Access is not restricted.
    2. protected : Access is limited to the containing class or types derived from the containing class.
    3. Internal : Access is limited to the current assembly.
    4. protected internal: Access is limited to the current assembly or types derived from the containing class.
    5. private : Access is limited to the containing type.

    Every members in C# are implicitly private, so in your question the a,b and c are defined as private and so you could not access to them from outside of methodTest. for more information you may need to look at this page : Access Modifiers (C# Programming Guide)

    Good Luck! :)

提交回复
热议问题