My list is declared as
private List<int> values = new List<int>{5, 2, 4, 10, 6, 7, 8, 9, 1};
How to get smallest element and key from this int list ?
My list is declared as
private List<int> values = new List<int>{5, 2, 4, 10, 6, 7, 8, 9, 1};
How to get smallest element and key from this int list ?
Take a look at List.Min< T >() or other version of List.Min().
private List<string> alphabets = new List<string>{"5", "2", "3", ...};
//Get Min
string smallestString = alphabets.Min();
//index
int index = alphabets.IndexOf( smallestString );