Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Type.GetTypeFromHandle() Method in C#
The Type.GetTypeFromHandle() method in C# is used to get the type referenced by the specified type handle.
Syntax
Following is the syntax −
public static Type GetTypeFromHandle (RuntimeTypeHandle handle);
Above, the handle parameter is the object that refers to the type.
Example
Let us now see an example to implement the Type.GetTypeFromHandle() method −
using System;
public class Demo {
public static void Main(){
Type type1 = typeof(short);
RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);
Type type = Type.GetTypeFromHandle(typeHandle);
Console.WriteLine("Attributes = " + type.Attributes);
}
}
Output
This will produce the following output −
Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit
Example
Let us now see another example to implement the Type.GetTypeFromHandle() method −
using System;
public class Demo {
public static void Main(){
Type type1 = typeof(System.Type);
RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);
Type type = Type.GetTypeFromHandle(typeHandle);
Console.WriteLine("Attributes = " + type.Attributes);
}
}
Output
This will produce the following output −
Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit
Advertisements
