using System.Collections.Generic;
public static void Main()
IList<int> intList = new List<int>() { 7, 10, 21, 30, 45, 50, 87 };
IList<string> strList = new List<string>() { null, "Two", "Three", "Four", "Five" };
IList<string> emptyList = new List<string>();
Console.WriteLine("Last Element in intList: {0}", intList.Last());
Console.WriteLine("Last Even Element in intList: {0}", intList.Last(i => i % 2 == 0));
Console.WriteLine("Last Element in strList: {0}", strList.Last());
Console.WriteLine("emptyList.Last() throws an InvalidOperationException");
Console.WriteLine("-------------------------------------------------------------");
Console.WriteLine(emptyList.Last());