Hi again,
This gives the max of even elements in an array:
Console.WriteLine("max even elements:" + myNumbers.Where(n => n % 2 == 0).Max());
But gives an error (InvalidOperation no elements ...) when there are no even elements in the array.
How to avoid that message? Thanks

Sachin SinghRank #66 · 26.2K reputationPosted Jun 18, 2021, 6:56 AM EDT
sir, simply check for null before calling any singleton method whether it be single(), Min(),Max() or Sum()
Valerie MeunierRank #1,527 · 1K reputationPosted Jun 18, 2021, 8:30 AM EDT