例如:
class Container { class Nested { Nested() { } } }
Nested 对外部类型是不可访问的,但可以设置为 public,如下所示:
class Container { public class Nested { Nested() { } } }
例如:
public class Container { public class Nested { private Container parent; public Nested() { } public Nested(Container parent) { this.parent = parent; } } }
嵌套类型可访问包含类型的私有成员和受保护的成员(包括所有继承的私有成员或受保护的成员)。
这是用来创建嵌套类的新实例的名称,如下所示:
Container.Nested nest = new Container.Nested();