Determines whether the List contains elements that match the conditions defined by the specified predicate.
using System; using System.Collections.Generic; public class Example { public static void Main() { List<string> myList = new List<string>(); myList.Add("A"); myList.Add("B"); myList.Add("C"); Console.WriteLine(); foreach (string d in myList) { Console.WriteLine(d); } Console.WriteLine(myList.TrueForAll(myFunc)); Console.WriteLine(myList.Find(myFunc)); Console.WriteLine(myList.FindLast(myFunc)); List<string> sublist = myList.FindAll(myFunc); foreach (string d in sublist) { Console.WriteLine(d); } Console.WriteLine(myList.RemoveAll(myFunc)); foreach (string d in myList) { Console.WriteLine(d); } Console.WriteLine(myList.Exists(myFunc)); } private static bool myFunc(String s) { if ((s.Length > 5) && (s.Substring(s.Length - 6).ToLower() == "C")) { return true; } else { return false; } } }