C# Language Events Standard Event Declaration

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Event declaration:

public event EventHandler<EventArgsT> EventName;

Event handler declaration:

public void HandlerName(object sender, EventArgsT args) { /* Handler logic */ }

Subscribing to the event:

Dynamically:

EventName += HandlerName;

Through the Designer:

  1. Click the Events button on the control's properties window (Lightening bolt)
  2. Double-click the Event name:

enter image description here

  1. Visual Studio will generate the event code:
private void Form1_Load(object sender, EventArgs e)
{

}

Invoking the method:

EventName(SenderObject, EventArguments);


Got any C# Language Question?