Understanding static anonymous functions
An anonymous function is a set of statements or expressions that can be used or executed whenever a delegate type is expected. With the use of anonymous functions, we might get unintended behavior if we accidentally refer to a local variable inside an anonymous function. With the use of static anonymous functions, we can avoid unintentional use of the state or local variables.
Consider the following code snippet to understand static anonymous functions:
string formatString = “Format String”; void GenerateSummary(string[] args) { GenerateOrderReport(() => { return formatString; }); } static string GenerateOrderReport(Func<string> getFormatString) { var order = new { Orderid = 1, ...