C# lambda expressions and delegates
Short answer
To create a lambda expression, specify input parameters (if any) on the left side of the lambda operator and an expression or a statement block on the other side. (S1) Lambdas are usually assigned to delegate types such as Func<> and Action<>, which are type-safe references to methods. [S1][S2]
Func<int, int> square = x => x * x;
Action<string> log = msg => { Console.WriteLine(msg); };
Key points
- Delegates let you pass methods as arguments, and event handlers are invoked through them. [S2]
- Assigned to
Expression<Func<...>>, a lambda becomes an expression tree instead of code (used by LINQ providers). [S1]
Claims
- id: C1 claim: The => operator separates a lambda's parameters from its body. source: S1 evidence: "Use the lambda declaration operator => to separate the lambda's parameter list from its body."
- id: C2 claim: A lambda can be assigned to a Func delegate. source: S1 evidence: "Func<int, int> square = x => x * x;"
- id: C3 claim: A delegate represents references to methods with a given signature. source: S2 evidence: "A delegate is a type that represents references to methods"
- id: C4 claim: Delegates pass methods as arguments to other methods. source: S2 evidence: "Delegates are used to pass methods as arguments to other methods."
Sources
- [S1] Lambda expressions - Lambda expressions and anonymous functions - C# reference. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-expressions . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.
- [S2] 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.
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), Lambda expressions - Lambda expressions and anonymous functions - C# reference, CC BY 4.0 (dotnet/docs); Microsoft Learn (.NET docs), Work with delegate types in C# - C#, CC BY 4.0 (dotnet/docs).
Cite this
iinventedlight. 2026. "C# lambda expressions and delegates." iinventedlight Library, iil:note:0qswyhpx, version of 2026-11-04. https://iinventedlight.com/library/notes/csharp-lambda-expressions/. License: CC-BY-4.0.
@misc{iil_note_0qswyhpx,
author = {{iinventedlight}},
title = {{C\# lambda expressions and delegates}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/csharp-lambda-expressions/},
note = {Permanent ID iil:note:0qswyhpx. 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-lambda-expressions.md.