using System;
using System.Collections.Generic;
using System.Linq;
namespace NilPointer
{
class Program
{
static void Main(string[] args)
{
var numbers = new List<int> {
50, 2, -7, 11,-9, 26, 6, 42
};
var max1 = numbers.Max(number => number);
Console.WriteLine("Max 1: " + max1);
var max2 = numbers.Where(number => number < 0).Max(number => number);
Console.WriteLine("Max 2: " + max2);
Console.ReadLine();
}
}
}
Output
Max 1: 50
Max 2: -7