Get the interface with the specified name in CSharp

Description

The following code shows how to get the interface with the specified name.

Example


using System;/*from ww w . j  av  a2  s. c  o  m*/
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 'IDeserializationCallback' Interface :");
        for (int index = 0; index < arrayMethodInfo.Length; index++)
            Console.WriteLine(arrayMethodInfo[index].ToString());

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Reflection »




Array
Constructor
Event
Field
Interface
Method
Properties
Type