I have some strings, and I would like to get the letter that is last in alphabetic order.
I know how to do it on a List (ordering the list), but what I would like is such a function :
private string getLastValue(string a, string b)
{
//????
}
getLastValue("a","b") may return "b"
getLastValue("azerty","qwerty") may return "qwerty"
>Solution :
You can just compare strings with a help of StringComparer, e.g.
private string getLastValue(string a, string b) =>
StringComparer.Ordinal.Compare(a, b) > 0 ? a : b;
Note, that you can choose the comparer required: Ordinal, OrdinalIgnoreCase etc.