I'm confused as to why this code won't compile:
var result = $"{fieldName}{isDescending ? " desc" : string.Empty}";
If I split it up, it works fine:
var desc = isDescending ? " desc" : string.Empty;
var result = $"{fieldName}{desc}";
I'm confused as to why this code won't compile:
var result = $"{fieldName}{isDescending ? " desc" : string.Empty}";
If I split it up, it works fine:
var desc = isDescending ? " desc" : string.Empty;
var result = $"{fieldName}{desc}";
According to the documentation:
The problem is that the colon is used to denote formatting, like
So, the tl;dr answer is: wrap the conditional in parenthesis.