The .NET Framework Standard Library: the System Namespace

Brad Abrams describes the System namespace, which is the root of all namespaces in the .NET Framework, containing all other namespaces as subordinates. It also contains the types that are the most fundamental and frequently used.

This chapter is from the book

The System namespace is the root of all namespaces in the .NET Framework, containing all other namespaces as subordinates. It also contains
the types that we felt to be the most fundamental and frequently used.

Basic Variable Types

The 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. Table 1 lists the value types in the System namespace.

Table 1.

Name

Represents

Boolean

Boolean value (true or false).

Byte

8-bit unsigned integer.

Char

UTF-16 code point.

DateTime

An instant in time, typically expressed as a date and time of day.

Decimal

Decimal number.

Double

Double-precision floating-point number.

Enum

Base class for enumerations.

Int16

16-bit signed integer.

Int32

32-bit signed integer.

Int64

64-bit signed integer.

SByte

8-bit signed integer.

Single

Single-precision floating-point number.

TimeSpan

Time interval.

UInt16

16-bit unsigned integer.

UInt32

32-bit unsigned integer.

UInt64

64-bit unsigned integer.

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. The
class String is a reference type that represents an immutable series of characters. The class CharEnumerator supports iterating over a String and reading its individual characters.

The System namespace also contains the abstract base class Array, which represents a fixed-size, ordered series of objects accessed by index. It contains methods for creating, manipulating,
and searching for elements within the array. Programmers will generally not use this class directly. Instead, their programming
language will provide an abstraction of it.