Phương thức Max có overload nhận selector lambda. Ví dụ: arr.Max(x => Math.Abs(x)) tìm giá trị tuyệt đối lớn nhất.
Ví dụ
using System;
using System.Linq;
class Demo
{
static void Main()
{
int[] arr = { 10, 90, 20, 19, 99, 57 };
Console.WriteLine(arr.Max(element => Math.Abs(element)));
}
}
Kết quả
99