Find the Second Max in a list of values using linq c#
var secondMax = ListOfNums.OrderByDescending(r => r).Skip(1).FirstOrDefault();
OR
var secondMax = ListOfNums.OrderByDescending(r=> r).Take(2).LastOrDefault();
just convert it to an array and take the second element
List<double> ListOfNums = new List<double> { 1, 5, 7, -1, 4, 8 };
var sndmax = ListOfNums.OrderByDescending(x => x).ToArray()[1];