Create the All query : All « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;


public class MainClass{

   public static void Main(string[] args){   

         String[] TestData = {"Zero", "One", "Two", "Three",
                              "Four", "Five", "Six", "Seven", 
                              "Eight", "Nine", "Ten"};

         var ThisQuery = TestData.All(ThisElement => ThisElement.Length == 4);

         Console.WriteLine("All elements have 4 characters: " + ThisQuery);
   }
}








22.17.All
22.17.1.Create the All query
22.17.2.All with condition
22.17.3.Using All to determine whether an array contains only odd numbers.
22.17.4.All with Predicate to Return True
22.17.5.All with string length
22.17.6.All method