This documentation is archived and is not being maintained.

RuntimeTypeHandle Structure

Represents a type using an internal metadata token.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Structure RuntimeTypeHandle
	Implements ISerializable
Dim instance As RuntimeTypeHandle

/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class RuntimeTypeHandle extends ValueType implements ISerializable
JScript suports the use of structures, but not the declaration of new ones.

The following example demonstrates how to obtain a RuntimeTypeHandle.

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

import System.*;
import System.Reflection.*;

public class MyClass1
    private int x = 0;

    public int MyMethod()
        return x;
    } //MyMethod
} //MyClass1

public class MyClass2
    public static void main(String[] args)
        MyClass1 myClass1 = new MyClass1();
        // Get the RuntimeTypeHandle from an object.
        RuntimeTypeHandle myRTHFromObject = Type.GetTypeHandle(myClass1);
        // Get the RuntimeTypeHandle from a type.
        RuntimeTypeHandle myRTHFromType = (MyClass1.class.ToType()).

        Console.WriteLine("myRTHFromObject.Value: {0}", myRTHFromObject.
        Console.WriteLine("myRTHFromObject.Type: {0}", myRTHFromObject.
        Console.WriteLine("myRTHFromType.Value: {0}", myRTHFromType.
        Console.WriteLine("myRTHFromType.Type: {0}", myRTHFromType.
} //MyClass2

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0