C# | Type.GetInterfaces() Method Last Updated : 08 Feb, 2023 Comments Improve Suggest changes Like Article Like Report 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 inherited by the current Type or an empty array of type if no interfaces are implemented or inherited by the current Type. Below programs illustrate the use of Type.GetInterfaces() Method: Example 1: C# // C# program to demonstrate the // Type.GetInterfaces() Method using System; using System.Globalization; using System.Reflection; class GFG { // Main Method public static void Main() { // Declaring and initializing object of Type Type objType = typeof(int); // Getting interface of specified name // using GetInterfaces(String) Method Type[] minterface = objType.GetInterfaces(); // Display the Result Console.WriteLine("Interface present in type {0}", objType); for (int i = 0; i < minterface.Length; i++) Console.WriteLine(" {0}", minterface[i]); } } Output: Interface present in type System.Int32 System.IFormattable System.IComparable System.IComparable`1[System.Int32] System.IConvertible System.IEquatable`1[System.Int32] Example 2: For if no public field is defined C# // C# program to demonstrate the // Type.GetInterfaces() Method using System; using System.Globalization; using System.Reflection; class GFG { // Main Method public static void Main() { // Declaring and initializing object of Type Type objType = typeof(string); // Getting interface of specified name // using GetInterfaces(String) Method Type[] minterface = objType.GetInterfaces(); // Display the Result Console.WriteLine("Interface present in type {0}", objType); for (int i = 0; i < minterface.Length; i++) Console.WriteLine(" {0}", minterface[i]); } } Output: Interface present in type System.String System.ICloneable System.Collections.Generic.IEnumerable`1[System.Char] System.IComparable System.IComparable`1[System.String] System.IConvertible System.Collections.IEnumerable System.IEquatable`1[System.String] Reference: https://docs.microsoft.com/en-us/dotnet/api/system.type.getinterfaces?view=netframework-4.8 Comment More infoAdvertise with us Next Article C# | Type.GetInterfaces() Method rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Type-Class Similar Reads 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.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.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.GetFields() Method Type.GetFields() Method is used to get the fields of the current Type. There are 2 methods in the overload list of this method as follows: GetFields() Method GetFields(BindingFlags) Method GetFields() Method This method is used to return all the public fields of the current Type. Syntax: public Syst 5 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 Like