22
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
IList<string> emptyList = new List<string>();
12
13
Console.WriteLine("1st Element in intList: {0}", intList.FirstOrDefault());
14
15
Console.WriteLine("1st Even Element in intList: {0}", intList.FirstOrDefault(i => i % 2 == 0));
16
17
Console.WriteLine("1st Element in strList: {0}", strList.FirstOrDefault());
18
19
Console.WriteLine("1st Element in emptyList: {0}", emptyList.FirstOrDefault());
20
21
}
22
}
Cached Result
Compilation error (line 43, col 13): 'int' does not contain a definition for 'Serialize' and no accessible extension method 'Serialize' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)
Compilation error (line 19, col 43): 'BinaryFormatter' is obsolete: 'BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.'
Compilation error (line 26, col 25): The variable 'e' is declared but never used
Compilation error (line 19, col 43): 'BinaryFormatter' is obsolete: 'BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.'
Compilation error (line 26, col 25): The variable 'e' is declared but never used