If you feel confident, you will create a static method whose sole purpose is to absorb the expression and say "do it."
public static class Extension { public static void Do(this Object x) { } }
Thus, you can call the ternary operator and call the extension method on it.
((x == y) ? Func1() : Func2()).Do();
Or, in an almost equivalent way, write a static method (if the class is limited when you want to use this "shortcut").
private static void Do(object item){ }
... and calling it that way
Do((x == y) ? Func1() : Func2());
However, I highly recommend not using this โshortcutโ for the same reasons that were already clear to the authors who were in front of me.
Erik burigo
source share