Why can't I use the conditional operator in an interpolated string without brackets? [duplicate]
问题 This question already has an answer here : How to use the ternary operator inside an interpolated string? (1 answer) Closed 2 years ago . Why can't I use the inline conditional-operator inside a c#-6 string interpolation, without encompassing it within brackets? and the errors: As you can see, it appears the parser is having a hard time. Is this a bug, or a feature of the string interpolation mechanism? 回答1: From MSDN (emphasis mine): $"{person.Name, 20} is {person.Age:D3} year {(p.Age == 1 ?