Flipping a Boolean

This is a very quick post but something i see from time to time. Sometimes I run into code like this:

if (someBool == false)
{ 
      someBool = true;
} 
else
{ 
      someBool = false;
}

which works, but it looks ugly and clutters up your code. The easier way to do something like this, is to simply

someBool = !someBool;

The reason for this is simple. What is “Not false”? True. What is “Not True”. False. I am going to guess that there are some performance┬ábenefits┬áto using this syntax but I have no research to back that up. Enjoy!