Namespaces and Classes

Chapter 6

Namespaces and Classes

As earlier chapters have discussed, the common language runtime computational model is inherently object-oriented. The concept of class—or, to use more precise runtime terminology, the concept of a type—is the central principle around which the entire computational model is organized. The type of an item—a variable, a constant, a parameter, and so on—defines both data representation and the behavioral features of the item. Hence one type can be substituted for another only if both these aspects are equivalent for both types—for instance, a derived type can be interpreted as the type from which it is derived.

The ECMA standard specification of the common language infrastructure divides types into value types and reference types, depending on whether an item type represents a data item itself or a reference (an address or a location indicator) to a data item.

Reference types include object types, interface types, and pointer types. Object types—classes—are types of self-describing values, either complete or partial. Types with partial self-describing values are called abstract classes. Interface types are always types of partial self-describing values. Interfaces usually represent subsets of behavioral features exposed by classes; a class is said to implement the respective interface. Pointer types are simply references to items, indicating item locations.

The common language runtime object model supports only single type inheritance, and multiple inheritance is simulated through implementation of multiple interfaces. Because of that, the runtime object model is absolutely hierarchical, with the System.Object class at the root of the tree. (See Figure 6-1.) Interface types, however, are not part of the type hierarchy because they are inherently incomplete and have no implementation of their own.

Figure 6-1 The common language runtime type hierarchy.

All types (except interfaces) are derived eventually from System.Object. This chapter examines types and their declarations, dividing the types into five categories: classes, interfaces, value types, enumerators, and delegates. These categories are not mutually exclusive—for example, delegates are classes and enumerators are value types—but the types of each category have distinct features.



Inside Microsoft. NET IL Assembler
Inside Microsoft .NET IL Assembler
ISBN: 0735615470
EAN: 2147483647
Year: 2005
Pages: 147
Authors: SERGE LIDIN

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net