
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Get the type referenced by the specified type handle in C#
To get the type referenced by the specified type handle, the code is as follows −
Example
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 see another example −
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
- Related Articles
- Get the handle for the Type of a specified object C#
- Get the specified members of the current Type in C#?
- C# Program to get the type of the specified Enumeration
- Get the underlying type of the current enumeration type C#
- Get a specific type nested within the current Type in C#
- Get all the interfaces implemented or inherited by the current Type in C#
- Get the fields of the current Type in C#
- Get the members of the current Type in C#
- Get a specific interface implemented or inherited by the current Type in C#
- Get the TypeCode for value type Char in C#
- Get the TypeCode for value type Decimal in C#
- Get the TypeCode for value type Int32 in C#
- Get the TypeCode for value type UInt64 in C#
- Get the TypeCode for value type UInt32 in C#
- Get the TypeCode for value type Int16 in C#

Advertisements