In C# you can find maximum or minimum value in a numeric array without by looping through the array;
For Getting the minimum value you can use MIN method and For Getting the maximum values you can use MAX method for the list items.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | static void Main(string[] args) { List<int> numbers = new List<int>(); numbers.Add(56); numbers.Add(42); numbers.Add(65); numbers.Add(42); Console.WriteLine("Max : "+numbers.Max()); Console.WriteLine("Min : "+numbers.Min()); Console.ReadKey(); } |
Output: