If I have the following test code:
Code:
String content = "This is a test";
String str = "This";
String lookFor = content.Substring(0, 5); // "This"
Boolean found = false;
// "found" should equal true, BUT IT'S NOT!!! Why??
if (str == lookFor)
found = true;
// "found" should equal true, BUT IT'S NOT!!! Why??
if (str.Equals(lookFor))
found = true;
// "found" should equal true, BUT IT'S NOT!!! Why??
switch (lookFor)
{
case "This":
found = true;
break;
}
In all three examples, "found" should be true, however, it never happens.
Where am I going wrong?
Thanks.