收录日期:2019/09/19 00:15:34 时间:2008-12-07 04:54:37 标签:c#,oop

by default is a class:

  1. private ?
  2. internal ?
  3. sealed ?

The default for non-nested types is internal. The default for nested types is private. In both cases the default (for classes) is unsealed.

The general rule for all members is that if you don't specify an access modifier, it's as private as it can be. The single exception for this is properties which can make one part (i.e. the getter or the setter) more private than the overall property by specifying an access modifier, e.g.

public string Foo { get; private set; }

Also, it is not sealed by default. I believe nested classes are private by default.

Top-level types, which are not nested into other types, can only have internal or public accessibility. The default accessibility for these types is internal.

Accessibility Levels (C#) on MSDN