Alex Rivera | Logout

Check if boolean is true?

Asked 2010-09-10T13:37:31.173
28
bool foo = true;

// Do this?
if (foo)
{
}

// Or this?
if (foo == true)
{
}

I like one of them and my coworker the other. The result is the same, but what is (more) correct?

c#
Edit
Report

1 Answer

1

Neither is "more correct". My personal preference is for the more concise form but either is fine. To me, life is too short to even think about arguing the toss over stuff like this.

answered 2010-09-10T13:40:46.037

Your Answer