Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetInterfaces Method
Collapse the table of content
Expand the table of content

Type.GetInterfaces Method

When overridden in a derived class, gets all the interfaces implemented or inherited by the current Type.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Public MustOverride Function GetInterfaces As Type()

Return Value

Type: System.Type()
An array of Type objects representing all the interfaces implemented or inherited by the current Type.
An empty array of type Type, if no interfaces are implemented or inherited by the current Type.




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

Imports System.Collections.Generic

Public Class Example

    Shared Sub Main()

        Console.WriteLine(vbCrLf & _
            "Interfaces implemented by Dictionary(Of Integer, String):" & vbCrLf)

        For Each tinterface As Type In GetType(Dictionary(Of Integer, String)).GetInterfaces()



        'Console.ReadLine()      ' Uncomment this line for Visual Studio.  
    End Sub 
End Class 

' This example produces output similar to the following: 

'Interfaces implemented by Dictionary(Of Integer, String): 

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
© 2015 Microsoft