C# Feature - Modifiers on simple lambda parameters
Modifiers on simple lambda parameters
Section titled “Modifiers on simple lambda parameters”C# 14 allows simple lambda parameter lists to include modifiers such as ref, out, in, ref readonly, and scoped without forcing explicit parameter types for every parameter.
Introduced In
Section titled “Introduced In”This feature was introduced in C# 14. The official Microsoft Learn page for C# 14 is dated November 18, 2025 and states that C# 14 ships with .NET 10 and Visual Studio 2026.
Why This Feature Exists
Section titled “Why This Feature Exists”Before C# 14, adding a modifier like out to a lambda parameter forced the lambda back into a fully typed parameter list. That made concise lambdas noticeably noisier.
Before
Section titled “Before”TryParse<int> parse = (string text, out int result) => int.TryParse(text, out result);TryParse<int> parse = (text, out result) => int.TryParse(text, out result);When To Use It
Section titled “When To Use It”- Use it when the delegate shape is already clear from the target type.
- Use it to keep lambdas concise in APIs that rely on
ref,out, or similar modifiers.
Common Pitfalls
Section titled “Common Pitfalls”- The
paramsmodifier still requires an explicitly typed parameter list. - If the target delegate is not obvious, the shorter syntax can make code harder to read.