C# delegates and events
Answer: A delegate is a type-safe reference to a method, which lets you pass methods as parameters and chain several together.
Delegates
Func<int, int> square = x => x * x;
Action<string> log = Console.WriteLine;
log += s => Debug.WriteLine(s); // multicast chain
log("hello"); // calls both
Events
class Downloader {
public event EventHandler<int>? Progress;
void Report(int pct) => Progress?.Invoke(this, pct);
}
var d = new Downloader();
d.Progress += (s, pct) => Console.WriteLine($"{pct}%");
In .NET, events conventionally use EventHandler or EventHandler<T> with EventArgs.
Notes
- An event can have many subscribers, and a subscriber can handle many events.
Claims
- id: C1 claim: Delegates allow methods to be passed as parameters. source: S1 evidence: "Delegates allow methods to be passed as parameters."
- id: C2 claim: Delegates can be chained together. source: S1 evidence: "Delegates can be chained together, such as calling multiple methods on a single event."
- id: C3 claim: The publisher decides when an event is raised; subscribers decide the response. source: S2 evidence: "The publisher determines when an event is raised; the subscribers determine what action is taken"
- id: C4 claim: An event can have multiple subscribers. source: S2 evidence: "An event can have multiple subscribers."
- id: C5 claim: .NET events are based on EventHandler and EventArgs. source: S2 evidence: "events are based on the EventHandler delegate and the EventArgs base class."
Sources
- [S1] Work with delegate types in C# - C#. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/ . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.
- [S2] Events - C#. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/events/ . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn (.NET docs), Work with delegate types in C# - C#, CC BY 4.0 (dotnet/docs); Microsoft Learn (.NET docs), Events - C#, CC BY 4.0 (dotnet/docs).
Cite this
iinventedlight. 2026. "C# delegates and events." iinventedlight Library, iil:note:hmexbda2, version of 2026-11-04. https://iinventedlight.com/library/notes/csharp-delegates-events/. License: CC-BY-4.0.
@misc{iil_note_hmexbda2,
author = {{iinventedlight}},
title = {{C\# delegates and events}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/csharp-delegates-events/},
note = {Permanent ID iil:note:hmexbda2. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/csharp-delegates-events.md.