C# Type GetInterface(String)
Description
Type GetInterface(String)
searches for the interface
with the specified name.
Syntax
Type.GetInterface(String)
has the following syntax.
public Type GetInterface(
string name
)
Parameters
Type.GetInterface(String)
has the following parameters.
name
- The string containing the name of the interface to get. For generic interfaces, this is the mangled name.
Returns
Type.GetInterface(String)
method returns An object representing the interface with the specified name, implemented
or inherited by the current Type, if found; otherwise, null.
Example
The following code example uses the GetInterface(String) method to search the Hashtable class for the IDeserializationCallback interface, and lists the methods of the interface.
using System;/* w w w . j ava 2 s . c om*/
using System.Reflection;
using System.Collections;
public class MainClas
{
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.