Underlying implementation will probably give the answer. Let's do it then,
GetType()
method and
UnderlyingSystemType
is from Type class from System namespace of the
mscorlib.dll
assembly.
GetType()
method has a implementation in the Type class with following implementation (based on the IL code extracted from
ILDasm tools)
public static Type GetType(string typeName)
{
StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;
return RuntimeType.GetType(typeName, false, false, false, ref lookForMyCaller);
}
we need to dive deeper into this method, if we look the implementation if the GetType(.....) of the RuntimeType class we can see behind the scene it is returning the RuntimType itself as,
internal static RuntimeType GetType(string typeName, bool throwOnError, bool ignoreCase, bool reflectionOnly, ref StackCrawlMark stackMark)
{
return RuntimeTypeHandle.GetTypeByName(typeName, throwOnError, ignoreCase, reflectionOnly, ref stackMark, false);
}
and the GetTypeByName method,
internal static RuntimeType GetTypeByName(string name, bool throwOnError, bool ignoreCase, bool reflectionOnly, ref StackCrawlMark stackMark, bool loadTypeFromPartialName)
{
RuntimeType o = null;
GetTypeByName(name, throwOnError, ignoreCase, reflectionOnly, JitHelpers.GetStackCrawlMarkHandle(ref stackMark), loadTypeFromPartialName, JitHelpers.GetObjectHandleOnStack<RuntimeType>(ref o));
return o;
}
but UnderlyingSystemType is marked as abstract property with the following implementation,
public abstract Type UnderlyingSystemType { get; }
This property has a implementation in the RuntimeType class in which is,
public override Type UnderlyingSystemType
{
get
{
return this;
}
}
So the both return the RuntimeType object as result. Hope it shows the internal of the
GetType()
and
UnderlyingSystemType
:)