Shortening boolean with if statement for document version comparison Can this be shortened to one line?

 bool areVersionsEqual = documentComparer.Equals(version, imported);

if (areVersionsEqual == false)
  {
    changedDocument.Add(imported); 
   }
Sure. Use the Not operator.

if (!documentComparer.Equals(version, imported))
{
    changedDocument.Add(imported); 
}




To explain a little, it's bad practice to do things like this.

bool boolean = true;
if (boolean == false)
{
//...


because it's completely equivalent to saying

if (true == false)


and can be simplified down to

if (false)