Calling a method on a lambda expression without requiring a variable declaration
- by Fikre
Given this extension method
public static void Until(this Action action, Func<bool> booleanFunc)
{
while (!booleanFunc())
action();
}
is it possible to turn this
var x = 0;
Action ac = () => x += 1;
ac.Until(() => x == 5);
into something of this sort
var x = 0;
(() => x += 1).Until(() => x == 5);
That is, a one liner?