C# TypeInfo GetInterface(String, Boolean)

Description

TypeInfo GetInterface(String, Boolean) When overridden in a derived class, searches for the specified interface, specifying whether to do a case-insensitive search for the interface name.

Syntax

TypeInfo.GetInterface(String, Boolean) has the following syntax.


public abstract Type GetInterface(
  string name,
  bool ignoreCase
)

Parameters

TypeInfo.GetInterface(String, Boolean) has the following parameters.

  • name - The string containing the name of the interface to get. For generic interfaces, this is the mangled name.
  • ignoreCase - true to ignore the case of that part of name that specifies the simple interface name (the part that specifies the namespace must be correctly cased).
  • ignoreCase - -or-
  • ignoreCase - false to perform a case-sensitive search for all parts of name.

Returns

TypeInfo.GetInterface(String, Boolean) method returns An object representing the interface with the specified name, implemented or inherited by the current Type, if found; otherwise, null.

Example


using System;// w  w  w  .  j  av  a  2  s.  c  om
using System.Security;
using System.Reflection;
using System.Collections;

public class MainClass
{
    public static void Main()
    {
        Hashtable hashtableObj = new Hashtable();
        Type objType = hashtableObj.GetType();
        MethodInfo[] arrayMethodInfo;

        arrayMethodInfo = objType.GetInterface("IDeserializationCallback").GetMethods();
        Console.WriteLine("\nMethods of 'IEnumerable' Interface");
        arrayMethodInfo = objType.GetInterface("ienumerable", true).GetMethods();
        for (int index = 0; index < arrayMethodInfo.Length; index++)
            Console.WriteLine(arrayMethodInfo[index].ToString());

    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo