In this case, my Truth variable is a variable with a null value. My question is simple
Will something be spelled wrong?
if ((bool)Truth) {}
or should i stick with this?
if (Truth == True) {}
Never worked with variables with null values not defined, if there is even a difference different from the other, is it possible if ((bool) Truth) {} took one more step?
. Truth - null, InvalidOperationException: Nullable object must have a value . , true . null , .
Truth
null
InvalidOperationException: Nullable object must have a value
true
, Jesse Slicer, , , , . , .
:
if (myBool.HasValue && myBool.Value)
, myBool (HasValue) true (Value ). , , if, nullable bool null.
, HasValue Value. Value, , , .
,
- bool, , bool, null, .
if (Truth == true) {}
Truth == null
Truth == false
? , . null , false, .
Nullable HasValue Value. HasValue == true Value.