Understanding Nested Type Definitions
The previous chapter briefly mentioned the concept of nested types, which is a spin on the “has-a”
relationship we have just examined. In C# (as well as other .NET languages), it is possible to define
a type (enum, class, interface, struct, or delegate) directly within the scope of a class or structure.
When you have done so, the nested (or “inner”) type is considered a member of the nesting (or
“outer”) class, and in the eyes of the runtime can be manipulated like any other member (fields,
properties, methods, events, etc.). The syntax used to nest a type is quite straightforward:
public class OuterClass
{
Do'stlaringiz bilan baham: |