Calling a method on a lambda expression without requiring a variable declaration
Posted
by
Fikre
on Stack Overflow
See other posts from Stack Overflow
or by Fikre
Published on 2010-12-28T09:17:23Z
Indexed on
2010/12/28
9:54 UTC
Read the original article
Hit count: 170
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?
© Stack Overflow or respective owner