Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 1.34 KB

File metadata and controls

28 lines (24 loc) · 1.34 KB
title add (C# Reference)
ms.date 07/20/2015
ms.prod .net
ms.technology
devlang-csharp
ms.topic article
f1_keywords
add_CSharpKeyword
helpviewer_keywords
add event accessor [C#]
ms.assetid faf30b99-10e8-45cd-ab9a-57585d4d1d8d
caps.latest.revision 7
author BillWagner
ms.author wiwagn

add (C# Reference)

The add contextual keyword is used to define a custom event accessor that is invoked when client code subscribes to your event. If you supply a custom add accessor, you must also supply a remove accessor.

Example

The following example shows an event that has custom add and remove accessors. For the full example, see How to: Implement Interface Events.

[!code-csharpcsrefKeywordsContextual#15]

You do not typically need to provide your own custom event accessors. The accessors that are automatically generated by the compiler when you declare an event are sufficient for most scenarios.

See Also

Events