Nov 01 2012 08:35 AM 7680 10 Second maximum number tmounika how to find out second maximum number in C#? Roger Hyde Feb 6th, 2016 Linq makes this quite simpleCodeint GetSecondMax(int[] numbers) { return numbers.Distinct().OrderByDescending(n => n).Skip(1).Take(1).FirstOrDefault(); } Vasyliy Zvarydchuk Profile Answers by Vasyliy Zvarydchuk Questions by Vasyliy Zvarydchuk Oct 28th, 2015 This code will work even if array will have a few maximums. Ex: (10, 8, 8, -2, 4, 10, 1) "c# static int GetSecondMax(int[] array) { if(array.Length < 2... Answer Question Select Best Answer
Nov 01 2012 08:35 AM 7680 10 Second maximum number tmounika how to find out second maximum number in C#? Roger Hyde Feb 6th, 2016 Linq makes this quite simpleCodeint GetSecondMax(int[] numbers) { return numbers.Distinct().OrderByDescending(n => n).Skip(1).Take(1).FirstOrDefault(); } Vasyliy Zvarydchuk Profile Answers by Vasyliy Zvarydchuk Questions by Vasyliy Zvarydchuk Oct 28th, 2015 This code will work even if array will have a few maximums. Ex: (10, 8, 8, -2, 4, 10, 1) "c# static int GetSecondMax(int[] array) { if(array.Length < 2... Answer Question Select Best Answer
Roger Hyde Feb 6th, 2016 Linq makes this quite simpleCodeint GetSecondMax(int[] numbers) { return numbers.Distinct().OrderByDescending(n => n).Skip(1).Take(1).FirstOrDefault(); }
Vasyliy Zvarydchuk Profile Answers by Vasyliy Zvarydchuk Questions by Vasyliy Zvarydchuk Oct 28th, 2015 This code will work even if array will have a few maximums. Ex: (10, 8, 8, -2, 4, 10, 1) "c# static int GetSecondMax(int[] array) { if(array.Length < 2...