Another thing you might want to consider is that the string.Contains method will perform case-sensitive searches.
var str = "The quick brown fox blah"; var test1 = "quick"; var test2 = "Quick"; Console.WriteLine(string.Format("{0} CONTAINS {1} = {2}", str, test1, str.Contains(test1))); Console.WriteLine(string.Format("{0} CONTAINS {1} = {2}", str, test2, str.Contains(test2)));
If you cannot use case insensitive for both of them to return true, you must first put the strings in lowercase ...
Console.WriteLine(string.Format("{0} CONTAINS {1} = {2}", str, test1, str.ToLower().Contains(test1.ToLower()))); Console.WriteLine(string.Format("{0} CONTAINS {1} = {2}", str, test2, str.ToLower().Contains(test2.ToLower())));
source share