Type::GetInterfaces Method
When overridden in a derived class, gets all the interfaces implemented or inherited by the current Type.
Assembly: mscorlib (in mscorlib.dll)
Return Value
Type: array<System::Type>An array of Type objects representing all the interfaces implemented or inherited by the current Type.
-or-
An empty array of type Type, if no interfaces are implemented or inherited by the current Type.
Implements
_Type::GetInterfaces()| Exception | Condition |
|---|---|
| TargetInvocationException | A static initializer is invoked and throws an exception. |
The GetInterfaces method does not return interfaces in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which interfaces are returned, because that order varies.
If the current Type represents a constructed generic type, this method returns the Type objects with the type parameters replaced by the appropriate type arguments.
If the current Type represents a type parameter in the definition of a generic type or generic method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.
The following example gets the type of the specified class and displays all the interfaces that the type implements or inherits. To compile the Visual Basic example, use the following compiler commands:
vbc type_getinterfaces1.vb /r:System.Web.dll /r:System.dll
using namespace System; using namespace System::Collections::Generic; void main() { Console::WriteLine("\r\nInterfaces implemented by Dictionary<int, String^>:\r\n"); for each (Type^ tinterface in Dictionary<int, String^>::typeid->GetInterfaces()) { Console::WriteLine(tinterface->ToString()); } //Console::ReadLine() // Uncomment this line for Visual Studio. } /* This example produces output similar to the following: Interfaces implemented by Dictionary<int, String^>: System.Collections.Generic.IDictionary`2[System.Int32,System.String] System.Collections.Generic.ICollection`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]] System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]] System.Collection.IEnumerable System.Collection.IDictionary System.Collection.ICollection System.Runtime.Serialization.ISerializable System.Runtime.Serialization.IDeserializationCallback */
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.