I assume that you really want to know if the object describes the Typeclass Type, but the object Typeis - typeof(RuntimeType)and not typeof(Type), and therefore comparing it typeof(Type)with fails.
What you can do is check if an instance of the type described by the object can be a type Typevariable Type. This gives the desired result, because it RuntimeTypecomes from Type:
private bool IsTypeOfType(Type type)
{
return typeof(Type).IsAssignableFrom(type);
}
Type, Type, GetType:
private bool IsRuntimeType(Type type)
{
return type == typeof(Type).GetType();
}
, typeof(Type) != typeof(Type).GetType(), .
:
IsTypeOfType(typeof(Type))
IsTypeOfType(typeof(Type).GetType())
IsTypeOfType(typeof(string))
IsTypeOfType(typeof(int))
IsRuntimeType(typeof(Type))
IsRuntimeType(typeof(Type).GetType())
IsRuntimeType(typeof(string))
IsRuntimeType(typeof(int))