在C#中布尔值默认值 [英] Default value for bool in c#
本文介绍了在C#中布尔值默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
公共BOOL PrepaymentCalculating {搞定;组; }
所以,我在我的班级像一个声明一个变量。我想这默认为'空',而不是假的。我只是需要让这个一个可空布尔?还是有更好的方式来做到这一点?
解决方案
请问我只是需要使这个可空布尔?
块引用>
是
还是有更好的方式来做到这一点?
块引用>
没有。
您可以实现这跟
公共BOOL? PrepaymentCalculating {搞定;组; }
public bool PrepaymentCalculating { get; set; }
So I declare a variable on one of my classes like that. I want this to default to 'null' and not false. Would I just need to make this a nullable boolean? Or is there a better way to do this?
解决方案Would I just need to make this a nullable boolean?
Yes.
Or is there a better way to do this?
No.
You can achieve this with
public bool? PrepaymentCalculating { get; set; }
这篇关于在C#中布尔值默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文