Compress to Lambda Expression (C#)
In This Article
Converts an anonymous method to a corresponding lambda expression.
#Purpose
This refactoring encourages the use of a more compact notation without manually re-structuring code.
#Availability
Available from the context menus or via shortcuts:
- when the caret is on a delegate statement within an anonymous method declaration.
#Example
Func<string, int> func = │delegate(string s) { return s.Length; };
Result:
Func<string, int> func = s => s.Length;