EventInfo.GetRemoveMethod Method (Boolean)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

When overridden in a derived class, retrieves the MethodInfo object for removing a method of the event, specifying whether to return non-public methods.

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

Syntax

'Declaration
Public MustOverride Function GetRemoveMethod ( _
    nonPublic As Boolean _
) As MethodInfo
public abstract MethodInfo GetRemoveMethod(
    bool nonPublic
)

Parameters

  • nonPublic
    Type: System.Boolean
    true to return the method if the current event is non-public; otherwise, false.

Return Value

Type: System.Reflection.MethodInfo
The method that is used to remove an event-handler delegate from the event source, or nulla null reference (Nothing in Visual Basic) if nonPublic is false and the method is not public.

Exceptions

Exception Condition
MemberAccessException

This member is invoked late-bound through mechanisms such as Type.InvokeMember.

Remarks

The method that is returned by GetRemoveMethod has a special name that consists of the prefix "remove_" followed by the name of the event, and is referred to as the remove accessor. The access level of the remove accessor is the same as the access level of the event. The remove accessor is called by compiled C# and Visual Basic code that unhooks event handlers, and by the RemoveEventHandler method, which is used to unhook event handlers in late-bound scenarios. It cannot be called directly from Visual Basic or C# source code. It can be called from dynamic code that is emitted by using the types in the System.Reflection.Emit namespace.

Version Information

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

Platforms

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