-1
var condition = false;
Foo($"String is {(condition ? "True" : "False")} works");
Foo($"String is {(condition ? "True"
: "False")} fails");
我编译错误,当我良好的格式化插值声明我的字符串中的条件运算符?
var condition = false;
Foo($"String is {(condition ? "True" : "False")} works");
Foo($"String is {(condition ? "True"
: "False")} fails");
我编译错误,当我良好的格式化插值声明我的字符串中的条件运算符?
使用@
Foo([email protected]"String is {(condition ? "True"
: "False")} fails");
但是我怎样才能使用像\ t那样的字符串文字呢? –
你不能。你必须选择一个'\ t'或'@' – Marusyk
使用逐字字符串....美孚($ @ “字符串是{(条件? ”真“ : ”假“)}失败”); –
感谢您的回复,但我通过使用$ @阅读了'解决方案',这很奇怪,因为条件运算符已经需要用括号分隔,因此它的内容不应该被解释为格式说明符了;使用$ @也不可能使用像\ t这样的格式文字... –