다음을 통해 공유


RuntimeTypeHandle 구조체

내부 메타데이터 토큰을 사용하여 형식을 나타냅니다.

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Structure RuntimeTypeHandle
    Implements ISerializable
‘사용 방법
Dim instance As RuntimeTypeHandle
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public struct RuntimeTypeHandle : ISerializable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public value class RuntimeTypeHandle : ISerializable
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class RuntimeTypeHandle extends ValueType implements ISerializable
JScript에서는 구조체를 사용할 수 있지만 새로 선언할 수는 없습니다.

예제

다음 예제에서는 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
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());

    }
}
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( "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

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

RuntimeTypeHandle 멤버
System 네임스페이스