Type.GetInterface Method (String)

Searches for the interface with the specified name.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public final function GetInterface(
	name : String
) : Type

Parameters

name
Type: System.String

The String containing the name of the interface to get. For generic interfaces, this is the mangled name.

Return Value

Type: System.Type
A Type object representing the interface with the specified name, implemented or inherited by the current Type, if found; otherwise, a null reference (Nothing in Visual Basic).

Implements

_Type.GetInterface(String)

ExceptionCondition
ArgumentNullException

name is a null reference (Nothing in Visual Basic).

AmbiguousMatchException

The current Type represents a type that implements the same generic interface with different type arguments.

The search for name is case-sensitive.

If the current Type represents a constructed generic type, this method returns the Type with the type parameters replaced by the appropriate type arguments.

If the current Type represents a type parameter in the definition of a generic type or generic method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.

NoteNote:

For generic interfaces, the name parameter is the mangled name, ending with a grave accent (`) and the number of type parameters. This is true for both generic interface definitions and constructed generic interfaces. For example, to find IExample<T> (IExample(Of T) in Visual Basic) or IExample<string> (IExample(Of String) in Visual Basic), search for "IExample`1".

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.

The code example also demonstrates the GetInterface(String, Boolean) method overload and the GetInterfaceMap method.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft