I am working on an application where we need to log entire statement of anonymous (lambda) function.
What it means is that the "LogAction" method should log all the statements that are passed as action.
protected void LogAction(Action action)
{
/*
Log the statement(s) passed to this method i.e. should print
var a = 10;
var b = 20;
Console.WriteLine($"Sum of {a} and {b} is {a+b}");
*/
}
LogAction(() =>
{
var a = 10;
var b = 20;
Console.WriteLine($"Sum of {a} and {b} is {a+b}");
});