Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value for bool in c#

Tags:

c#

.net

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?

like image 533
slandau Avatar asked Feb 14 '11 19:02

slandau


1 Answers

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; }
like image 93
jason Avatar answered Oct 11 '22 22:10

jason