C# | Type.GetTypeArray() Method Last Updated : 18 Jan, 2023 Comments Improve Suggest changes Like Article Like Report 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 corresponding elements in args. Exception: This method throws ArgumentNullException if args is null or, One or more of the elements in args is null. Below programs illustrate the use of Type.GetTypeArray() Method: Example 1: csharp // C# program to demonstrate the // Type.GetTypeArray(Object[]) Method using System; using System.Globalization; using System.Reflection; // Defining class Empty public class Empty { } class GFG { // Main Method public static void Main() { // try-catch block for handling Exception try { // creating and initializing object object[] obj = {2, 3.4, 'c', "ram"}; // using GetTypeArray() Method Type[] type = Type.GetTypeArray(obj); // Display the Result Console.WriteLine("Types of the objects in the specified array: "); for (int i = 0; i < type.Length; i++) Console.WriteLine(" {0}", type[i]); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.Write("One or more of the elements in args is null."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output:Types of the objects in the specified array: System.Int32 System.Double System.Char System.String Example 2: csharp // C# program to demonstrate the // Type.GetTypeArray(Object[]) Method using System; using System.Globalization; using System.Reflection; // Defining class Empty public class Empty {} class GFG { // Main Method public static void Main() { // try-catch block for handling Exception try { // creating and initializing object object[] obj = {2, 3.4, 'c', "ram", null}; // using GetTypeArray() Method Type[] type = Type.GetTypeArray(obj); // Display the Result Console.WriteLine("Types of the objects in the specified array: "); for (int i = 0; i < type.Length; i++) Console.WriteLine(" {0}", type[i]); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.WriteLine("One or more of the elements in args is null."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output:One or more of the elements in args is null. Exception Thrown: System.ArgumentNullException Reference: https://docs.microsoft.com/en-us/dotnet/api/system.type.gettypearray?view=netframework-4.8 Comment More infoAdvertise with us Next Article C# | Type.GetTypeArray() Method rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Type-Class Similar Reads C# | Type.GetArrayRank() Method Type.GetArrayRank() Method is used to get the number of dimensions in an array. Syntax: public virtual int GetArrayRank ();Return Value: This method returns an integer which contains the number of dimensions in the current type.Exception: This method throws ArgumentException if the current type is n 2 min read C# | Type.GetTypeHandle() Method 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. E 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.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.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 C# | Type.GetInterfaces() Method Type.GetInterfaces() Method is used to get all the interfaces implemented or inherited by the current Type when overridden in a derived class. Syntax: public abstract Type[] GetInterfaces ();Return Value: This method returns an array of Type objects representing all the interfaces implemented or inh 2 min read C# | Type.GetNestedType() Method Type.GetNestedType() Method is used to get a specific type nested within the current Type. There are 2 methods in the overload list of this method as follows: GetNestedType(String, BindingFlags) Method GetNestedType(String) Method GetNestedType(String, BindingFlags) Method This method is used to sea 4 min read C# | Type.GetElementType() Method Type.GetElementType() Method is used to return the Type of the object encompassed or referred to by the current array, pointer or reference type when overridden in a derived class. Syntax: public abstract Type GetElementType (); Return Value: This method returns the Type of the object encompassed or 2 min read C# | Type.GetNestedTypes() Method Type.GetNestedTypes() Method is used to get the types nested within the current Type. There are 2 methods in the overload list of this method as follows: GetNestedTypes() Method This method is used to return the public types nested in the current Type. Syntax: public Type[] GetNestedTypes ();Return 5 min read C# | Type.GetMember() Method Type.GetMember() Method is used to get the specified members of the current Type. There are 3 methods in the overload list of this method as follows: GetMember(String) Method GetMember(String, BindingFlags) Method GetMember(String, MemberTypes, BindingFlags) Method GetMember(String) Method This meth 6 min read Like