event (C# Reference) 

The event keyword is used to specify an event.

Remarks

Events are used on classes and structs to notify objects of occurrences that may affect their state. For example, Windows Forms have an System.Windows.Forms.Form.Activated event that can be used to trigger code whenever the form has become active.

To add an event to a class requires using the event keyword, and providing a delegate type and a name for the event. In this example, a delegate is defined, and then associated with the event SampleEvent.

public delegate void SampleEventDelegate(object sender, EventArgs e);
public class SampleEventSource
{
    public event SampleEventDelegate SampleEvent;
}

For more information, see the sections Events (C# Programming Guide) and Delegates (C# Programming Guide).

C# Language Specification

For more information, see the following sections in the C# Language Specification:

  • 1.6.6.4 Events

  • 7.13.3 Event Assignment

  • 10.7 Events

  • 13.2.3 Interface Events

See Also

Reference

C# Keywords
Modifiers (C# Reference)

Concepts

C# Programming Guide

Other Resources

C# Reference