using System.Collections.Generic;
public static void Main()
List<Employee> employees = new List<Employee>()
new Employee() { EIN = 1, FirstName = "John", LastName = "Doe", Salary= 55000M },
new Employee() { EIN = 2, FirstName = "Jane", LastName = "Doe", Salary= 55000M },
new Employee() { EIN = 3, FirstName = "Don", LastName = "DeLuth", Salary= 55000M },
IEnumerable<Person> people = new List<Person>()
new Person() { FirstName = "Tom", LastName = "Jones" },
new Person() { FirstName = "Henry", LastName = "Holy" },
new Person() { FirstName = "Barry", LastName = "Bonds" },
IReadOnlyCollection<Person> directory = employees;
int numStaff = directory.Count;
Console.WriteLine("numStaff = {0}", numStaff);
private static void Covariance(IEnumerable<Person> list)
IList<Person> personList = list.ToList();
Console.WriteLine("numStaff = {0}", personList.Count);
Console.WriteLine("numStaff = {0}", personList.FirstOrDefault().FirstName);
Console.WriteLine("numStaff = {0}", personList.FirstOrDefault().LastName);
private static void Contravariance(IEnumerable<Employee> list)
IList<Employee> personList = list.ToList();
Console.WriteLine("numStaff = {0}", personList.Count);
Console.WriteLine("numStaff = {0}", personList.FirstOrDefault().FirstName);
Console.WriteLine("numStaff = {0}", personList.FirstOrDefault().LastName);
public string FirstName { get; set; }
public string LastName { get; set; }
public class Employee : Person
public int EIN { get; set; }
public Decimal Salary { get; set; }