What are the default access modifiers in C#?

后端 未结 9 1391
暖寄归人
暖寄归人 2020-11-22 03:44

What is the default access modifier for classes, methods, members, constructors, delegates and interfaces?

9条回答
  •  死守一世寂寞
    2020-11-22 03:50

    Class is Internal by default.

    • Class members are private by default.

    Interface is Internal by default.

    • Interface members are public by default. (Interfaces won't allow us to specify any kind of accessibility to it's members.)

      Note: If you try to specify any access specifier to interface's members then, it shows compile error.

    Struct is Internal by default.

    • Struct members are private by default.

提交回复
热议问题