1
votes

i know there is an extension method to find max and min of array.

Using this code where i have to call that method to find max and min values ?

while trying number[].Max();

"Max" there is no intelligence for max method

How may achieve with this code

        var numbers = new float[]
        {
         1.0f, 3.5f, -7.8f, 10f
        };
        Console.WriteLine("Min: {0}", numbers[2]);
        Console.WriteLine("Max: {0}", numbers[4]);
        Console.ReadLine();
1

1 Answers

8
votes
Console.WriteLine("Min: {0}", numbers.Min());
Console.WriteLine("Max: {0}", numbers.Max());

Don't forget to include System.Linq namespace