• Question

  • Hi Everyone,

    Why this code return true

    Console.WriteLine(Enumerable.Empty<string>().All(s => s.Length == 3));


    Tuesday, November 30, 2010 6:39 PM


  • Good question,

    I am not 100% sure but I'll take a stab at it, I would guess because a enum of nothing is returned  (Black Hole) .All has no enum items to check against so therefore anything is true.

    In other words there are no items in the enum to test against so, the length of All items in the enum can equal anything because in actuality there are no items at all.

    Ex. If you had no apples then would it be fair to say all your apples are green.  Sure, because you have none.

    Matthew Hazlett
    Clarity Computers
    • Marked as answer by liurong luo Tuesday, December 7, 2010 5:46 AM
    Wednesday, December 1, 2010 5:02 PM