#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
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #951 – Not Every Type Derives from object

  1. Pingback: Dew Drop – October 14, 2013 (#1,644) | Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: