Absolutely - you could use ??
in the same way as any other binary operator, meaning that you could have any expression on its left and/or on its right.
For example, you could do something like this:
int? a = ...
int? b = ...
int? c = ...
int? d = ...
int? res = (condition_1 ? a : b) ?? (condition_2 ? c : d);
This expression will evaluate (condition_1 ? a : b)
first, check if it's null
, and then either use the non-null value as the result, or evaluate the right-hand side, and us it as the result.
You can also "chain" the null coalesce operators ??
, like this:
int? res =a ?? b ?? c ?? d;
Evaluation of this expression goes left to right.