Nested\Inner classes are considered to be within the scope of the Enclosing\Outer class and are available for use within that scope.
The inner class has access to all the methods and fields of the top-level class, even the private ones.
The inner class's short name may not be used outside its scope. If you absolutely must use it, you can use the fully qualified name instead.
Example :-
public class Outer
{
public class Nested
{
public void DisplayA(Outer o) {
System.Console.WriteLine(o.A);
}
}
private int A;
}
To make the object of nested class :-
Outer.Nested n1 = new Outer.Nested();
No comments:
Post a Comment