Type::GetInterface Method

When overridden in a derived class, searches for the specified interface, specifying whether to do a case-insensitive search for the interface name.

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

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

Parameters

name
Type: System::String
The String containing the name of the interface to get. For generic interfaces, this is the mangled name.
ignoreCase
Type: System::Boolean
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).
-or-
false to perform a case-sensitive search for all parts of 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, nullptr.

ExceptionCondition
ArgumentNullException

name is nullptr.

AmbiguousMatchException

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

The ignoreCase parameter applies only to the simple interface name, not to the namespace. The portion of name that specifies the namespace must have the correct case, or the interface will not be found. For example, the string "System.icomparable" finds the IComparable interface, but the string "system.icomparable" does not.

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 example uses the GetInterface(String, Boolean) method overload to perform a case-sensitive search of the generic Dictionary<TKey, TValue> class for the generic IDictionary<TKey, TValue> interface.

The example also demonstrates the GetInterfaceMap method.

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

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: