May 27, 2010, 3:52 p.m.
posted by irds
Basic Variable TypesThe class Object is the root of the inheritance hierarchy in the .NET Framework. Every class in the .NET Framework ultimately derives from this class. If you define a class without specifying any other inheritance, Object is the implied base class. It provides the most basic methods and properties that all objects need to support, such as returning an identifying string, returning a Type object (think of it as a class descriptor) to use for runtime discovery of the object's contents, and providing a location for a garbage collection finalizer. The .NET Framework provides two kinds of types, value types and reference types. Instances of value types are allocated on the stack or inline inside an object, which incurs a lower overhead than using the managed heap. Value types are most often used for small, lightweight variables accessed primarily for a single data value, while still allowing them to be treated as objects in the inheritance hierarchy (for example, having methods). All value types must derive from the abstract base class ValueType. Figure lists the value types in the System namespace covered in this volume of the .NET Framework Standard Library Annotated Reference.
All objects that are not value types are by definition reference types. Creating an instance of a reference type allocates the new object from the managed heap and returns a reference to it, hence the name. Most objects are reference types. |
- Comment