19
1
using System;
2
using System.Linq;
3
using System.Collections.Generic;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
IList<int> intList = new List<int>() { 7, 10, 21, 30, 45, 50, 87 };
10
IList<string> strList = new List<string>() { null, "Two", "Three", "Four", "Five" };
11
12
Console.WriteLine("1st Element which is greater than 250 in intList: {0}", intList.First( i => i > 250));
13
14
//The following will throw an exception
15
//Console.WriteLine("1st Even Element in intList: {0}", strList.FirstOrDefault(s => s.Contains("T")));
16
17
18
}
19
}
Cached Result
True
False
False