Is the predicate true for all words in the list - CSharp LINQ

CSharp examples for LINQ:IEnumerable

Description

Is the predicate true for all words in the list

Demo Code



using System;/*from   ww  w.  ja va2 s  .c o m*/
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
        int[] numArray = numbers.ToArray();
        List<string> words = new List<string> { "one", "two", "three", "four", "five" };

        bool trueForAll = words.TrueForAll(word => word.Length > 2);
        Console.WriteLine("\tAll words have more than 2 characters: {0}", trueForAll.ToString());

    }
}

Result


Related Tutorials