Ternary operator requires a return value, so wrap your method in a delegate and return some dummy value(in this case true
). You're done..
int count = 0;
Func<bool> func1 = () =>
{
count++;
push();
return true;//To make compiler happy
};
Func<bool> func2 = () =>
{
count++;
push();
return true;//To make compiler happy
};
var dummy = (check) ? func1() : func2();