Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem here is that this is really two questions - one question is about inheritance, in which case the answer is "nearly everything", and the other is about reference type vs value type/memory/boxing, which case the answer is "no".</p> <p><strong>Inheritance:</strong></p> <p>In C#, the following is true:</p> <ul> <li>All value types, including enums and nullable types, are derived from <code>System.Object</code>. </li> <li>All class, array, and delegate types are derived from <code>System.Object</code>.</li> <li>Interface types are not derived from <code>System.Object</code>. They are all convertible to <code>System.Object</code>, but interfaces only derive from other interface types, and <code>System.Object</code> is not an interface type. </li> <li>No pointer types derive from <code>System.Object</code>, nor are any of them directly convertible to <code>System.Object</code>.</li> <li>"Open" type parameter types are also not derived from <code>System.Object</code>. Type parameter types are not derived from anything; type arguments are constrained to be derived from the effective base class, but they themselves are not "derived" from anything.</li> </ul> <p>From <a href="http://msdn.microsoft.com/en-us/library/system.object.aspx" rel="noreferrer">the MSDN entry for System.Object</a>:</p> <blockquote> <p>Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all classes in the .NET Framework; it is the root of the type hierarchy.</p> <p>Languages typically do not require a class to declare inheritance from Object because the inheritance is implicit.</p> <p>Because all classes in the .NET Framework are derived from Object, every method defined in the Object class is available in all objects in the system. Derived classes can and do override some of these methods.</p> </blockquote> <p>So not every type in C# is derived from <code>System.Object</code>. And even for those types that are, you still need to note the difference between <a href="http://msdn.microsoft.com/en-us/library/490f96s2.aspx" rel="noreferrer">reference types</a> and <a href="http://msdn.microsoft.com/en-us/library/s1ax56ch.aspx" rel="noreferrer">value types</a>, as they are treated very differently.</p> <p><strong>Boxing:</strong></p> <p>While value types do <em>inherit</em> from <code>System.Object</code>, they are treated differently in memory from reference types, and the semantics of how they are passed through methods in your code are different as well. Indeed, a value type is not treated as an Object (a reference type), until you explicitly instruct your application to do so by boxing it as a reference type. See <a href="http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx" rel="noreferrer">more information about boxing in C# here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload