RuntimeTypeHandle (Estructura)
Representa un tipo utilizando un símbolo (token) de metadatos interno.
Espacio de nombres: System
Ensamblado: mscorlib (en mscorlib.dll)
Ensamblado: mscorlib (en mscorlib.dll)
En el siguiente ejemplo se muestra cómo obtener RuntimeTypeHandle.
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()); } }
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()).
get_TypeHandle();
Console.WriteLine("myRTHFromObject.Value: {0}", myRTHFromObject.
get_Value());
Console.WriteLine("myRTHFromObject.Type: {0}", myRTHFromObject.
GetType());
Console.WriteLine("myRTHFromType.Value: {0}", myRTHFromType.
get_Value());
Console.WriteLine("myRTHFromType.Type: {0}", myRTHFromType.
GetType());
}//main
} //MyClass2
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter Edition
.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.
Contenido de la comunidad
Agregar