Type.GetInterfaces Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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()
public abstract Type[] GetInterfaces()

Return Value

Type: array<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.


Exception Condition

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.

Imports System.Collections.Generic

Public Class Example

    Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

        outputBlock.Text &= _
            "Interfaces implemented by Dictionary(Of Integer, String):" & vbLf
        For Each ti As Type In GetType(Dictionary(Of Integer, String)).GetInterfaces()

            outputBlock.Text &= ti.ToString() & vbLf

    End Sub
End Class

' This example produces output similar to the following:
'Interfaces implemented by Dictionary(Of Integer, String):

using System;
using System.Collections.Generic;

public class Example
    public static void Demo(System.Windows.Controls.TextBlock outputBlock)
        outputBlock.Text += 
            "Interfaces implemented by Dictionary<int, string>:\n";
        foreach (Type ti in typeof(Dictionary<int, string>).GetInterfaces())
            outputBlock.Text += ti.ToString() + "\n";

/* This example produces output similar to the following:

Interfaces implemented by Dictionary<int, string>:

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0


Windows Phone

See Also


Type Class

System Namespace