0

What is the difference between

This

var ext = name.LastIndexOf(@".");

and This

var ext = name.LastIndexOf(@".", System.StringComparison.Ordinal);
Bart
  • 43
  • 2

1 Answers1

2

From the StringComparison enum documentation on MSDN:

An operation that uses ordinal sort rules performs a comparison based on the numeric value (Unicode code point) of each Char in the string. An ordinal comparison is fast but culture-insensitive. When you use ordinal sort rules to sort strings that start with Unicode characters (U+), the string U+xxxx comes before the string U+yyyy if the value of xxxx is numerically less than yyyy.

The extra parameter is telling the method how to compare strings. With Ordinal, it's going to use unicode code points for the comparison. Other values of the enum use the culture (invariant or the current one) and can use case insensitive comparison.

dee-see
  • 23,668
  • 5
  • 58
  • 91