C# Type GetInterfaces

Description

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

Syntax

Type.GetInterfaces has the following syntax.


public abstract Type[] GetInterfaces()

Returns

Type.GetInterfaces method returns

Example

The following example gets the type of the specified class and displays all the interfaces that the type implements or inherits.


/*from www  . j a va 2 s . c  o m*/
using System;
using System.Collections.Generic;

public class Example
{
    static void Main()
    {
        Console.WriteLine("\r\nInterfaces implemented by Dictionary<int, string>:\r\n");

        foreach (Type tinterface in typeof(Dictionary<int, string>).GetInterfaces())
        {
            Console.WriteLine(tinterface.ToString());
        }

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version