C# – how can I declare multiple bools as false

cnet

Instead of declaring:

bool one = false;
bool two = false;
bool three = false;

Is it possible to declare something like:

bool one, two, three;

while setting them all to false ?

bool one, two, three = false

Best Answer

The default value of a bool variable is false. The default value of a bool? variable is null.

For reference you can visit: bool (C# Reference).

But you cannot use it unless assigned with values.

bool one, two, three;
one = two = three = false

The same goes with nullable boolean:

bool? isCase = null;
if (isCase.HasValue){
    //TODO:
   }