<分区>
而不是声明:
bool one = false;
bool two = false;
bool three = false;
是否可以声明如下内容:
bool one, two, three;
同时将它们全部设置为 false
?
bool one, two, three = false
<分区>
而不是声明:
bool one = false;
bool two = false;
bool three = false;
是否可以声明如下内容:
bool one, two, three;
同时将它们全部设置为 false
?
bool one, two, three = false
最佳答案
The default value of a bool variable is false. The default value of a bool? variable is null.
引用您可以访问:bool (C# Reference).
但除非分配
值,否则您不能使用它。
bool one, two, three;
one = two = three = false
可空 bool 值也是如此:
bool? isCase = null;
if (isCase.HasValue){
//TODO:
}
关于c# - 如何将多个 bool 值声明为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45976499/