Tuesday, October 15, 2013

#951 – Not Every Type Derives from object

    C# is normally said to have a Unified Type System, that is–every type derives from object (System.Object), directly or indirectly.

This is mostly true, but not completely accurate.

Most types do derive from object, including: classes, value types, and delegates.  And all object instances that you work with will be instances of types that do derive from object.  (Or they will have a null value).

But there are several types that do not derive from object, including:
  • Interface - an interface is a type that does not derive from object.  Rather, an interface can be implemented by some type that does derive from object.

QR: Inline images 1