Skip to main content

Expand Lambda Expression (C#)

Converts the lambda expression to an equivalent anonymous method.

#Availability

Available from the context menu or via shortcuts:

  • when the caret is on the left side of a lambda operator or on a lambda operator (=>).

#Notes

  • This refactoring is the functional opposite of Expand Lambda Expression (C#).

#Example

Func<string, int> func = s => s.Length;

Result:

Func<string, int> func = delegate(string s) 
{
    return s.Length;
};

#Screenshot

rsExpandLambdaExpression