// C# Program to check whether a List contains
// the elements that match the specified conditions
// defined by the predicate
using System;
using System.Collections;
using System.Collections.Generic;
class Geeks {
// function which checks whether an
// element is even or not. Or you can
// say it is the specified condition
private static bool isEven(int i)
{
return ((i % 2) == 0);
}
// Main Method
public static void Main(String[] args)
{
// Creating an List<T> of Integers
List<int> firstlist = new List<int>();
// Adding elements to List
for (int i = 1; i <= 10; i++) {
firstlist.Add(i);
}
Console.WriteLine("Elements Present in List:\n");
// Displaying the elements of List
foreach(int k in firstlist)
{
Console.WriteLine(k);
}
Console.WriteLine(" ");
Console.Write("Result: ");
// Check the elements of firstlist that
// match the conditions defined by predicate
Console.WriteLine(firstlist.Exists(isEven));
}
}