I cannot find the relationships between these types using .Net reflector. Any idea?
Asked
Active
Viewed 175 times
6
-
Nice question, i'm interesting too but i think you cannot see it in reflector cause only keywords like scruct or enum defines type as value for compiler. – Denis Agarev Aug 02 '12 at 07:29
-
1@Denis you can see it in the IL, the C# and the tree... – Marc Gravell Aug 02 '12 at 07:30
-
the object browser in VS should also give you the same information... – jl. Aug 02 '12 at 07:37
1 Answers
8
Since you say "using .Net reflector":
If you wanted reflection:
Type type = typeof (int);
while(type != null)
{
Console.WriteLine(type.FullName);
type = type.BaseType;
}
which shows:
System.Int32
System.ValueType
System.Object
and if you mean the IL:
.class public sequential ansi serializable sealed beforefieldinit Int32
extends System.ValueType
and:
.class public abstract auto ansi serializable beforefieldinit ValueType
extends System.Object
(in reflector, select the type's node, and select IL as the view)
If you mean the C# view, then:
public struct Int32 ...
is enough; the struct
keyword means: inherits from ValueType
(although not quite in the usual C# class
way). ValueType
remains a regular class, and has:
public abstract class ValueType ...
and as usual, a class
which doesn't specify a base-type means: inherits from object
.

Marc Gravell
- 1,026,079
- 266
- 2,566
- 2,900
-
I mean the C# view. Everyting is clear now. Thanks Marc for giving different approaches which is great. – user1033098 Aug 02 '12 at 07:33