Check if the List contains elements that match the conditions defined by the specified predicate in CSharp
Description
The following code shows how to check if the List contains elements that match the conditions defined by the specified predicate.
Example
using System;//from w w w. j ava 2 s. c om
using System.Collections.Generic;
public class Example
{
public static void Main()
{
List<string> myData = new List<string>();
myData.Add("B");
myData.Add("D");
Console.WriteLine(myData.Exists(MyCondition));
}
private static bool MyCondition(String s)
{
return s.ToLower().EndsWith("a");
}
}
The code above generates the following result.