if (greaterAB)
and
if (greaterAB == true)
are equivalent and the first version should be preferred.
In C# you can't use an un-initialized identifier and in fact you initialize
greaterAB
:
bool greaterAB = (a > b);
So at this point it reflects the fact whether
a
is greater than
b
and a boolean's default value of
false
has nothing to do with all this. Now if you had declared
greaterAB
as a class variable (which wouldn't make much sense) then it would be initialized to the default value of
false
the first time the static class is being used or, if it's a non-static class, an object of that class is instantiated.