Code inspection: Lambda expression/anonymous method can be made 'static'
This inspection reports a lambda expression that does not capture anything from the enclosing scope and can therefore be marked static. Making such lambdas static documents that they are capture-free and prevents accidental captures later.
Example
Action<int> log = (int p) =>
{
Console.WriteLine(p);
};
Action<int> log = static (int p) =>
{
Console.WriteLine(p);
};
Quick-fix
Add the static modifier to the lambda expression.
30 March 2026