Object

We kept one of the most interesting types for the last: System.Object, otherwise known as object in C#. What’s so special about this one? Recall that the .NET Framework is based on the principles of object-oriented programming (OOP). In this setting, types form a hierarchy; we pay much more attention to OOP in later chapters.

Every type in .NET, except for System.Object, has a base type from which it inherits code as well as data. This sentence already gives it away. Because System.Object doesn’t have a base type, it should necessarily be the (only) root of the type hierarchy. Although this may sound of interest only for theoretical purposes, it has a very practical side to it: unifying the type system across value and reference types. ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.