Does every type in .net inherit from System.Object?

.net, c#

Solution

Eric Lippert has covered this in a blog entry: Not everything derives from object (This is the title of the blog entry; not the answer to this question. Don't get confused.)

Yes, all `struct`s inherit from `System.ValueType` which in turn inherits from `System.Object`. `enum`s you declare inherit from `System.Enum` which inherits from `System.ValueType`.

Update:

Inherently, there's not a problem with a value type being derived from a reference type. Inheritance is a "is-a" relationship between two types. However, in order to treat a value type as an object instance, it has to be boxed. This is done implicitly when you are passing a value to a method that expects an object parameter (or when you call instance methods implemented in `System.Object`.)

Problem

This might be a very basic question, but I am a bit confused about it. If I reflect the Int32/Double/any value type code, I see that they are structs and look like : ``` [Serializable, StructLayout(LayoutKind.Sequential), ComVisible(true)] public struct Double : IComparable, IFormattable, IConvertible, IComparable<double>, IEquatable<double> { .... } ``` So, why do we say that everything in .NET is derived from System.Object. I think am missing some crucial point here. EDIT: What confuses me further is that how can a value type which is struct inherit from System.Object which is a class.

Original source

Related problems