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?

Oh my, it's late at night! I just realized I had ';' at the end of the line of my if statement. Well, that was silly. Wish I could delete this thread.

i think u need a break from programming .. :)

Bhuvan that's Blasphemy!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.