There is a null coalescing operator (??
), but it would not handle empty strings.
If you were only interested in dealing with null strings, you would use it like
string output = somePossiblyNullString ?? "0";
For your need specifically, there is the conditional operator bool expr ? true_value : false_value
that you can use to simplify if/else statement blocks that set or return a value.
string output = string.IsNullOrEmpty(someString) ? "0" : someString;