Protecting Nested Classes
You can nest classes inside other classes in C#, and nested classes can access members of the host class, even private members. Nested classes work much like any other class member when it comes to inheritance; for example, say that that the Window class has a nested Point class, which keeps track of the upper-left point of the window. We might make the Point class protected like this:
public class Window { private Point location; public Window(int x, int y) { this.location = new Point(x, y); } public Window() { this.location = new Point(100, 100); } public virtual void Open() { System.Console.WriteLine("Opening window at [{0}, {1}]", location.x, location.y); } protected class Point { public int x, y; public ...
Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.