这是否是if else声明

use*_*910 5 c# if-statement

可能重复:
C#中两个问号共同意味着什么?

我刚刚看到下面的代码,并不确定它是什么意思,不能谷歌它因为谷歌省略了 ??

int? x = 32;
int  y = x ?? 5;
Run Code Online (Sandbox Code Playgroud)

第二行是某种if else语句,是什么??意思

saj*_*saj 12

它被称为null-coalescing运算符.

如果该值的左边??就是null,然后使用该值的权 ??,否则用左手值.

扩大:

y = x == null ? 5 : x
Run Code Online (Sandbox Code Playgroud)

要么

if(x == null)
     y = 5
else
     y = x
Run Code Online (Sandbox Code Playgroud)