When I call a Linq (not Linq-for-SQL, just simple in-memory Linq) – what locale it uses to compare objects, and how can I affect it?
E.g.
string[] a = { 'a', 'b', ... }; string max = a.Max();
What locale is used here – current, invariant? How can I affect it? The comparision seems to be case-insensitive, what if I want to find case-sensitive max?
It uses the implementation of
IComparable<string>in string.You could fairly easily write your own version of Max which does take an
IComparer<T>for comparisons – I’m very surprised there isn’t one already. Alternatively, you could use Aggregate in a somewhat cumbersome way to accomplish the same result.