November 2002
Intermediate to advanced
560 pages
11h 16m
English
You can define types inside of other types, known as nested types. Nested types have access to the members of their enclosing types as well as to the members of their enclosing type's base class (subject to the normal accessibility conditions, as will be discussed shortly). Listing 2.11 demonstrates their use. This program defines three different object types: Outer, Middle, and Inner. Inner contains the entry point and accesses the enumerations defined in its enclosing types.
using System; namespace NestedTypes { class Outer { private enum Day {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; class Middle { private enum Month {January = 1, February, March, April, May, June, July, August, ... |
Read now
Unlock full access