RuntimeTypeHandle Structure
Represents a type using an internal metadata token.
For a list of all members of this type, see RuntimeTypeHandle Members.
System.Object
System.ValueType
System.RuntimeTypeHandle
[Visual Basic] <Serializable> Public Structure RuntimeTypeHandle Implements ISerializable [C#] [Serializable] public struct RuntimeTypeHandle : ISerializable [C++] [Serializable] public __value struct RuntimeTypeHandle : public ISerializable
[JScript] In JScript, you can use the structures in the .NET Framework, but you cannot define your own.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Example
[Visual Basic, C#, C++] The following example demonstrates how to obtain a RuntimeTypeHandle.
[Visual Basic] Imports System Imports System.Reflection _ Public Class MyClass1 Private x As Integer = 0 Public Function MyMethod() As Integer Return x End Function 'MyMethod End Class 'MyClass1 _ Public Class MyClass2 Public Shared Sub Main() Dim myClass1 As New MyClass1() ' Get the RuntimeTypeHandle from an object. Dim myRTHFromObject As RuntimeTypeHandle = Type.GetTypeHandle(myClass1) ' Get the RuntimeTypeHandle from a type. Dim myRTHFromType As RuntimeTypeHandle = GetType(MyClass1).TypeHandle Console.WriteLine("myRTHFromObject.Value: {0}", myRTHFromObject.Value) Console.WriteLine("myRTHFromObject.Type: {0}", myRTHFromObject.GetType()) Console.WriteLine("myRTHFromType.Value: {0}", myRTHFromType.Value) Console.WriteLine("myRTHFromType.Type: {0}", myRTHFromType.GetType()) End Sub 'Main End Class 'MyClass2 [C#] using System; using System.Reflection; public class MyClass1 { private int x=0; public int MyMethod() { return x; } } public class MyClass2 { public static void Main() { MyClass1 myClass1 = new MyClass1(); // Get the RuntimeTypeHandle from an object. RuntimeTypeHandle myRTHFromObject = Type.GetTypeHandle(myClass1); // Get the RuntimeTypeHandle from a type. RuntimeTypeHandle myRTHFromType = typeof(MyClass1).TypeHandle; Console.WriteLine("myRTHFromObject.Value: {0}", myRTHFromObject.Value); Console.WriteLine("myRTHFromObject.Type: {0}", myRTHFromObject.GetType()); Console.WriteLine("myRTHFromType.Value: {0}", myRTHFromType.Value); Console.WriteLine("myRTHFromType.Type: {0}", myRTHFromType.GetType()); } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; public __gc class MyClass1 { private: int x; public: int MyMethod() { return x; } }; int main() { MyClass1* myClass1 = new MyClass1(); // Get the RuntimeTypeHandle from an object. RuntimeTypeHandle myRTHFromObject = Type::GetTypeHandle(myClass1); // Get the RuntimeTypeHandle from a type. RuntimeTypeHandle myRTHFromType = __typeof(MyClass1)->TypeHandle; Console::WriteLine(S"myRTHFromObject.Value: {0}",__box( myRTHFromObject.Value)); Console::WriteLine(S"myRTHFromObject.Type: {0}", __box(myRTHFromObject)->GetType()); Console::WriteLine(S"myRTHFromType.Value: {0}",__box( myRTHFromType.Value)); Console::WriteLine(S"myRTHFromType.Type: {0}", __box(myRTHFromType)->GetType()); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: Mscorlib (in Mscorlib.dll)