C# Type GetTypeFromHandle

Description

Type GetTypeFromHandle gets the type referenced by the specified type handle.

Syntax

Type.GetTypeFromHandle has the following syntax.


public static Type GetTypeFromHandle(
  RuntimeTypeHandle handle
)

Parameters

Type.GetTypeFromHandle has the following parameters.

  • handle - The object that refers to the type.

Returns

Type.GetTypeFromHandle method returns The type referenced by the specified RuntimeTypeHandle, or null if the Value property of handle is null.

Example

The following example uses the GetTypeFromHandle method to get a Type object from a RuntimeTypeHandle provided by the GetTypeHandle method.


using System;/*from w ww. j  a  v a 2  s  .  c  om*/

public class MainClass{
  public static void Main(String[] argv){  
        MainClass myClass1 = new MainClass();
        Type myClass1Type = Type.GetTypeFromHandle(Type.GetTypeHandle(myClass1));
        Console.WriteLine("The Names of the Attributes :"+myClass1Type.Attributes);

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version