首页 > Windows开发 > 详细

C# bool? 的意思

时间:2018-02-25 18:28:17      阅读:208      评论:0      收藏:0      [点我收藏+]

bool? is nullable while bool is not.

bool? first;
bool second;

In the above code, first will be null while second will be false.

 

The ? symbol after a type is only a shortcut to the Nullable typebool? is equivalent to Nullable<bool>.

bool is a value type, this means that it cannot be null, so the Nullable type basically allows you to wrap value types, and being able to assign null to them.

bool? can contain three different values: truefalse and null.

x        y      x & y   x | y   
true    true    true    true
true    false   false   true
true    null    null    true
false   true    false   true
false   false   false   false
false   null    false   null
null    true    null    true
null    false   false   null
null    null    null    null


REF: https://stackoverflow.com/questions/1181491/whats-the-difference-between-bool-and-bool

C# bool? 的意思

原文:https://www.cnblogs.com/watermarks/p/8469780.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!