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 SinghPosted Jun 18, 2021, 10:56 AM
sir, simply check for null before calling any singleton method whether it be single(), Min(),Max() or Sum()
Valerie MeunierPosted Jun 18, 2021, 12:30 PM