RuntimeTypeHandle Structure
Represents a type using an internal metadata token.
Assembly: mscorlib (in mscorlib.dll)
| Name | Description | |
|---|---|---|
![]() | Value | Gets a handle to the type represented by this instance. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Indicates whether the specified object is equal to the current RuntimeTypeHandle structure.(Overrides ValueType::Equals(Object^).) |
![]() | Equals(RuntimeTypeHandle) | Indicates whether the specified RuntimeTypeHandle structure is equal to the current RuntimeTypeHandle structure. |
![]() | GetHashCode() | Returns the hash code for the current instance.(Overrides ValueType::GetHashCode().) |
![]() | GetModuleHandle() | Gets a handle to the module that contains the type represented by the current instance. |
![]() | GetObjectData(SerializationInfo^, StreamingContext) | Populates a SerializationInfo with the data necessary to deserialize the type represented by the current instance. |
![]() | GetType() | |
![]() | ToString() | Returns the fully qualified type name of this instance.(Inherited from ValueType.) |
| Name | Description | |
|---|---|---|
![]() ![]() | Equality(Object^, RuntimeTypeHandle) | Indicates whether an object and a RuntimeTypeHandle structure are equal. |
![]() ![]() | Equality(RuntimeTypeHandle, Object^) | Indicates whether a RuntimeTypeHandle structure is equal to an object. |
![]() ![]() | Inequality(Object^, RuntimeTypeHandle) | Indicates whether an object and a RuntimeTypeHandle structure are not equal. |
![]() ![]() | Inequality(RuntimeTypeHandle, Object^) | Indicates whether a RuntimeTypeHandle structure is not equal to an object. |
The following example demonstrates how to obtain a RuntimeTypeHandlefrom a type or from an object, and how to turn the handle back into a type.
using namespace System; using namespace System::Reflection; public ref class MyClass1 { private: int x; public: int MyMethod() { return x; } }; int main() { MyClass1^ myClass1 = gcnew MyClass1; // Get the RuntimeTypeHandle from an object. RuntimeTypeHandle myRTHFromObject = Type::GetTypeHandle( myClass1 ); // Get the RuntimeTypeHandle from a type. RuntimeTypeHandle myRTHFromType = MyClass1::typeid->TypeHandle; Console::WriteLine( "\nmyRTHFromObject.Value: {0}", myRTHFromObject.Value ); Console::WriteLine( "myRTHFromObject.GetType(): {0}", myRTHFromObject.GetType() ); Console::WriteLine( "Get the type back from the handle..." ); Console::WriteLine( "Type::GetTypeFromHandle(myRTHFromObject): {0}", Type::GetTypeFromHandle(myRTHFromObject) ); Console::WriteLine( "\nmyRTHFromObject.Equals(myRTHFromType): {0}", myRTHFromObject.Equals(myRTHFromType) ); Console::WriteLine( "\nmyRTHFromType.Value: {0}", myRTHFromType.Value ); Console::WriteLine( "myRTHFromType.GetType(): {0}", myRTHFromType.GetType() ); Console::WriteLine( "Get the type back from the handle..." ); Console::WriteLine( "Type::GetTypeFromHandle(myRTHFromType): {0}", Type::GetTypeFromHandle(myRTHFromType) ); } /* This code example produces output similar to the following: myRTHFromObject.Value: 3295832 myRTHFromObject.GetType(): System.RuntimeTypeHandle Get the type back from the handle... Type::GetTypeFromHandle(myRTHFromObject): MyClass1 myRTHFromObject.Equals(myRTHFromType): True myRTHFromType.Value: 3295832 myRTHFromType.GetType(): System.RuntimeTypeHandle Get the type back from the handle... Type::GetTypeFromHandle(myRTHFromType): MyClass1 */
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



