How to check condition on all elements using Lambda Expressions?

static void Main(string[] args)
{
    List<int> list = new List<int>();
    list.Add(1);
    list.Add(2);
    list.Add(3);
    list.Add(4);
    list.Add(5);

    bool result = list.All(e => e > 0);
    Console.WriteLine(result.ToString());
    Console.ReadKey(false);
}

Leave a Reply

Your email address will not be published. Required fields are marked *