I have the following lines of code, where an if statement compares two strings:
string strFound = @"Testing";
string strTest = @"Testing";
if (strFound.Equals(strTest))
{
++iCount; // This line executes when strFound == strTest as expected
}
if (!(strFound.Equals(strTest)));
{
++iCount;// Surprisingly this line always executes even when strFound == strTest
}
if (strFound != strTest)
++iCount; // This line always executes even when strFound == strTest
I'm stepping through this in debug (VS 2012, .net 4.5) and watching the two string variables. They absolutely are equivalent, BUT for some reason the boolean logic is failing. Anyone have an idea why? Is there something silly I'm missing?