.NET boolean condition

What would be the difference if I check if the boolean ouput is true by the two ? should putting .equals necessary in .net ? Thanks.

if test.Equals(True)

if test

If you input a bool variable in the judgment condition, it will be executed according to the true or false of the variable. If you input bool = ture / false, it will be judged according to the result of the expression

1 Like


I think it’s not necessary, in general. And I recommend to name the variable meaningful like buttonExists etc.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.