Compares this instance with a specified object or String and returns an integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified object or String.
Determines whether two String objects have the same value.
Always using equals when you just want to check whether two strings are the same or not, since equals is constant time (due to string interning), where compare to take O(length of string) time.
- Use Ordinal or StringComparison.OrdinalIgnoreCase for comparisons as your safe default for culture-agnostic string matching.
- Use comparisons with Ordinal or StringComparison.OrdinalIgnoreCase for better performance.
- Use the ToUpperInvariant method instead of the String.ToLowerInvariant method when you normalize strings for comparison. (you can find reason here)