Ordinal simply does a direct comparison of the Unicode character numbers. (Note: Unicode is a superset of ASCII.) InvariantCulture, on the other hand, knows about special rules. It represents the rules for a "neutral" culture and for the most part does things in a way that would be considered normal in the United States. There is also CurrentCulture, which will respect the user's actual region.
Here is an example where this affects equality:
Console.WriteLine(String.Equals("æ", "ae", StringComparison.Ordinal)); // Prints false
Console.WriteLine(String.Equals("æ", "ae", StringComparison.InvariantCulture)); // Prints true
If your goal is to determine if there is anything different about the two strings, you definitely want to compare for Ordinal equality. If you want to take into account special language rules, then you will need to go with one of the choices.
Marked as answer byliurong luoMonday, February 02, 2009 10:12 AM