This documentation is archived and is not being maintained.

Type.GetInterfaces Method

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

[Visual Basic]
Public MustOverride Function GetInterfaces() As Type()
public abstract Type[] GetInterfaces();
public: virtual Type* GetInterfaces() [] = 0;
public abstract function GetInterfaces() : Type[];

Return Value

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 Type Condition
TargetInvocationException A static initializer is invoked and throws an exception.


[Visual Basic, C#, C++] 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:

[Visual Basic, C#, C++] vbc type_getinterfaces1.vb /r:System.Web.dll /r:System.dll

[Visual Basic] 

Imports System
Imports System.Web
Imports System.Web.UI
Imports Microsoft.VisualBasic

Namespace Samples
    Public Class MyTemplate
        Inherits Control
        Implements INamingContainer
        Private _message As [String] = Nothing
        Public Property Message() As [String]
                Return _message
            End Get
            Set(ByVal Value As [String])
                _message = value
            End Set
        End Property
    End Class
    Public Class MyInterfacesSample
        Public Shared Sub Main()
                Dim myObjectArray As Type() = GetType(MyTemplate).GetInterfaces()
                Console.WriteLine("The interfaces inherited by the MyTemplate class are:" + ControlChars.CrLf)
                Dim index As Integer
                For index = 0 To myObjectArray.Length - 1
                Next index
            Catch e As Exception
                Console.WriteLine("An exception occurred.")
                Console.WriteLine("Message: {0}", e.Message)
            End Try
        End Sub
    End Class
End Namespace


using System;
using System.Web;
using System.Web.UI;

namespace Samples
    public class MyTemplate : Control, INamingContainer 
        private String _message = null;
        public String Message 
                return _message;
                _message = value;
    public class MyInterfacesSample
        public static void Main()
                Type[] myObjectArray= typeof(MyTemplate).GetInterfaces();
                Console.WriteLine("The interfaces inherited by the MyTemplate class are:\n");
                for (int index = 0; index < myObjectArray.Length; index++)
            catch (Exception e)
                Console.WriteLine("An exception occurred.");
                Console.WriteLine("Message: " + e.Message);


#using <mscorlib.dll>
#using <system.dll>
#using <system.web.dll>

using namespace System;
using namespace System::Web;
using namespace System::Web::UI;

public __gc class MyTemplate : public Control, public INamingContainer
   String* _message;
   __property String* get_Message() {

      return _message;

   __property void set_Message(String* value) {

      _message = value;


int main() {
   try {
      Type* myObjectArray[]= __typeof(MyTemplate)->GetInterfaces();
      Console::WriteLine(S"The interfaces inherited by the MyTemplate class are:\n");
      for (int index = 0; index < myObjectArray->Length; index++) {
   } catch (Exception* e) {
      Console::WriteLine(S"An exception occurred.");
      Console::WriteLine(S"Message: {0}", e->Message);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Type Class | Type Members | System Namespace | GetInterface | FindInterfaces