Bewerken

Share via


IDynamicInterfaceCastable.IsInterfaceImplemented Method

Definition

Called when an implementing class instance is cast to an interface type that is not contained in the class's metadata.

public:
 bool IsInterfaceImplemented(RuntimeTypeHandle interfaceType, bool throwIfNotImplemented);
public bool IsInterfaceImplemented (RuntimeTypeHandle interfaceType, bool throwIfNotImplemented);
abstract member IsInterfaceImplemented : RuntimeTypeHandle * bool -> bool
Public Function IsInterfaceImplemented (interfaceType As RuntimeTypeHandle, throwIfNotImplemented As Boolean) As Boolean

Parameters

interfaceType
RuntimeTypeHandle

The interface type.

throwIfNotImplemented
Boolean

Indicates if the function should throw an exception instead of returning false.

Returns

true if this object can be cast to the given interface; otherwise, false.

Remarks

This is called if casting this object to the given interface type would otherwise fail. Casting here means the IL isinst and castclass instructions in the case where they are given an interface type as the target type. If throwIfNotImplemented is false, this function should avoid throwing exceptions. If throwIfNotImplemented is true and this function returns false, then InvalidCastException will be thrown unless an exception is thrown by the implementation.

Applies to