#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.
  • dynamic – dynamic is a type in that you can declare variables to be of type dynamic, but it is not an actual type in the CLR that derives from object (although its semantics are similar to the semantics of object)
  • System.TypedReference – does not derive from object