EventInfo.GetAddMethod Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns the method that is used to add an event-handler delegate to the event source.

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

Syntax

Public Function GetAddMethod As MethodInfo
public MethodInfo GetAddMethod()

Return Value

Type: System.Reflection..::.MethodInfo
The method that is used to add an event-handler delegate to the event source, or nullNothingnullptra null reference (Nothing in Visual Basic) if 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 GetAddMethod has a special name that consists of the prefix "add_" followed by the name of the event, and is referred to as the add accessor. The access level of the add accessor is the same as the access level of the event. The add accessor is called by compiled C# and Visual Basic code that hooks up event handlers, and by the AddEventHandler method, which is used to hook up 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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

EventInfo Class

GetAddMethod Overload

System.Reflection Namespace

MethodInfo