String comparison: InvariantCultureIgnoreCase vs OrdinalIgnoreCase?

c#, string

Solution

If you really want to match only the dot, then `StringComparison.Ordinal` would be fastest, as there is no case-difference.

"Ordinal" doesn't use culture and/or casing rules that are not applicable anyway on a symbol like a `.`.

Problem

Which would be better code: ``` int index = fileName.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase); ``` or ``` int index = fileName.LastIndexOf(".", StringComparison.OrdinalIgnoreCase); ```

Original source

Related problems