!=
, respectively!=
operators differs from string comparison using the String.CompareTo and Compare(String, String) methods. While the tests for equality perform a case-sensitive ordinal comparison, the comparison methods perform a case-sensitive, culture-sensitive comparison using the current culture. Because the default comparison methods often perform different types of comparisons, we recommend that you always make the intent of your code clear by calling an overload that explicitly specifies the type of comparison to perform.ShowWhere
displays information about where the string was found. If the string was not found, the returned value indicates where it would be if it were found.ShowWhere
shows where the sought text is or would be:string
. In general, you should use these constructors whenever possible, and specify either StringComparer.Ordinal or StringComparer.OrdinalIgnoreCase.a
and b
are interned meaning they share the same storage. The strings a
and c
are not.!=
operators when you test for equality. The String.CompareTo instance methods always perform an ordinal case-sensitive comparison. They are primarily suited for ordering strings alphabetically.