C# | Type.GetTypeHandle() Method Last Updated : 22 May, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Type.GetTypeHandle() Method is used to get the handle for the Type of a specified object. Syntax: public static RuntimeTypeHandle GetTypeHandle (object o); Here, it takes the object for which to get the type handle. Return Value: This method returns The handle for the Type of the specified Object. Exception: This method throws ArgumentNullException if o is null. Below programs illustrate the use of Type.GetTypeHandle() Method: Example 1: csharp // C# program to demonstrate the // Type.GetTypeHandle() Method using System; using System.Globalization; using System.Reflection; class GFG { // Main Method public static void Main() { // try-catch block for handling Exception try { // creating and initializing object Type Type type = typeof(int); // getting handle of given type // by using GetTypeHandle() Method RuntimeTypeHandle handle = Type.GetTypeHandle(type); // Display the Result Console.WriteLine("Type referenced is {0}", handle); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.WriteLine("object is null."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Type referenced is System.RuntimeTypeHandle Example 2: csharp // C# program to demonstrate the // Type.GetTypeHandle() Method using System; using System.Globalization; using System.Reflection; class GFG { // Main Method public static void Main() { // try-catch block for handling Exception try { // creating and initializing object Type Type type = typeof(int); // getting handle of given type // by using GetTypeHandle() Method RuntimeTypeHandle handle = Type.GetTypeHandle(null); // Display the Result Console.WriteLine("Type referenced is {0}", handle); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.WriteLine("object is null."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: object is null. Exception Thrown: System.ArgumentNullException Reference: https://docs.microsoft.com/en-us/dotnet/api/system.type.gettypehandle?view=netframework-4.8 Comment More infoAdvertise with us Next Article C# | Type.GetTypeHandle() Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Type-Class Similar Reads C# | Type.GetTypeFromHandle() Method Type.GetTypeFromHandle() Method is used to get the type referenced by the specified type handle. Syntax: public static Type GetTypeFromHandle (RuntimeTypeHandle handle); Here, it takes the object which refers to the type. Return Value: This method returns the type referenced by the specified Runtime 2 min read C# | Type.GetTypeCode() Method Type.GetTypeCode() Method is used to get the underlying type code of the specified Type. Syntax: public static TypeCode GetTypeCode (Type type); Here, it takes the type whose underlying type code to get. Return Value: This method returns the code of the underlying type, or Empty if type is null. Bel 2 min read C# | Type.GetTypeArray() Method Type.GetTypeArray() Method is used to get the types of the objects in the specified array. Syntax: public static Type[] GetTypeArray (object[] args); Here, it takes an array of objects whose types to determine. Return Value: This method returns an array of Type objects representing the types of the 2 min read C# | Type.GetHashCode() Method Type.GetHashCode() Method is used to return the hash code for this instance. Syntax: public override int GetHashCode (); Return Value: This method returns the hash code for the current instance. Below programs illustrate the use of Type.GetHashCode() Method: Example 1: csharp // C# program to demons 2 min read C# | Type.GetInterface() Method Type.GetInterface() Method is used to gets a specific interface implemented or inherited by the current Type. GetInterface(String) Method This method is used to search for the interface with the specified name. Syntax: public Type GetInterface (string name); Here, it takes the string containing the 4 min read Like