可能重复:
AND操作不能在可空的bool之间应用.
我期待类似的行为,如+或*.因此,如果任何操作数为null,则它应返回null,但如果在&&或||中使用它,则编译会抱怨.为什么?
为了说明这一点:
//this compiles
int? x = null;
int? y = null;
var z = x*y;
// this doesn't compile
bool? x = null;
bool? y = null;
if(x && y)
....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1943 次 |
| 最近记录: |