C# --- ??(空接合操作符)的一个案例

1 Nullable<Int32> x = null;
2 Nullable<Int32> y = null;
3 Nullable<Int32> z = null;
4 Int32 res = x ?? y ?? z ?? 110;

等价于:

 1 if (null != x)
 2 {
 3     res = x.Value;
 4 }
 5 else
 6 {
 7     if (null != y)
 8     {
 9         res = y.Value;
10     }
11     else
12     {
13         if (null != z)
14         {
15             res = z.Value;
16         }
17         else
18         {
19             res = 110;
20         }
21     }
22 }
原文地址:https://www.cnblogs.com/luguoshuai/p/10675772.html