Nested classes are defined in the class or structure.
class Container{ class Nested { Nested() { } }}
<1> the default access permission for nested classes is private, which can be set to public, protected, private, internal, and protected internal.
<2> the nested type can access the external class (the class of the nested class). To access the external type, you need to pass the external class to an instance through the constructor.
<3> A nested class can only access static members of an external class, but cannot directly access non-static members of an external class.
Namespace ConsoleApplication11Anonymous {class Class1 {private int x; protected string str; static int y; public class Nested {int xx; string ss; void print () {// int y = x; // error, cannot access external non-static member int z = y; // OK, can access external static member} public Nested (Class1 A) {xx =. x; // access an external class private member ss =. str; // access the external class protection member through an external class instance} class Program {static void Main (string [] args) {Class1 X = new Class1 (); class1.Nested CN = new Class1.Nested (X );}}}