I am trying to check if a string contains a specific string or not.
In short, here is my code (which is a small part of the program where I skipped irrelevant codes):
string y = someValue; for(string x in someCollection) { if (x.Contains(y)) { Debug.WriteLine(x + " Contains " + y); } else { Debug.WriteLine(x + " Does Not Contain " + y); } }
However, this is what I get as a result:
"Alligator" Contains "Alligator" "Loves" Does Not Contain "Love" "To Eat You" Does Not Contain "You"
So, how did it happen!?! Does Contains () return true only when both strings are exact matches? Something is wrong here...
ps. line x and y were read from a text file and went through the text processing process if that helps ...
source share