Can these ternary expression with expensive method calls be simplified without outline variables ...

I do NOT want to

  • call expensive methods more than once.
  • make "outline" temporary variables. Outline variables are ones declared outside ternary expressions.
  • leak variables with letters.
var out1 = ExpensiveMethod1(x, y) is bool __ ? __.ToString() : "null";
var out2 = ExpensiveMethod2(x, y) is bool ___ ? ___.ToString() : "null";
var out3 = ExpensiveMethod3(x, y) is bool ____ ? ____.ToString() : "null";

where bool? ExpensiveMethod*<T,U>(T t, U u){}.

Can these expression be simplified even further?
Was this page helpful?