0

I'm trying to write

$"This is { awesomeEnough ? "awesome" : "not awesome"}"

but I'm getting compiler error

CS1003 Syntax error, ':' expected

is it expecting behavior or bug?

Jason Smith
  • 105
  • 7
  • The `:` delimits the expression from the formatting in interpolated strings so you have to force it to not think it's that delimiter by put the expression inside parenthesis `$"This is { (awesomeEnough ? "awesome" : "not awesome")}"` – juharr Apr 11 '17 at 11:48

1 Answers1

4

Operator priority. Parenthesis should solve the problem

$"This is { (awesomeEnough ? "awesome" : "not awesome") }"
Perfect28
  • 11,089
  • 3
  • 25
  • 45