GetType()
is defined as extern
in base Object.
As far as I know, .NET source code (I use .NET 4.6) does not even
provide the source code for any extern
method. Does anybody know
where the source code for GetType()
is?
I am trying to learn the boxing of simple types and I use GetType()
for various tests. Technically, when you run it on a literal/variable
of simple type then the literal/variable is automatically boxed
so what is the Type returned by GetType()
supposed to represent?
My tests show it is pre-boxed type which is problematic because
GetType()
is run on a boxed type. Even if I cast a variable of
simple type into an object first, and run GetType()
on this object itself
then the returned Type still shows simple type. Also, if I declare
a variable of nullable simple type like int? and run GetType()
on it
then Type.IsValueType = True
and Type.IsPrimitive = True
(IsPrimitive should be false). Only when I check Type returned by
typeof(int?)
I get Type.IsValueType = True
and Type.IsPrimitive = False