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.