using System.Collections.Generic;
public static void Main()
var p1 = new Person{Name="Alice", Surname="Alridge"};
var p2 = new Student{Name="Bobby", Surname="Bean", Id="ax023"};
var p3 = new Student{Name="Charlie", Surname="Cumbs", Id="fy015"};
IList<Person> l0 = new List<Person>{p1,p2,p3};
IList<Student> l1 = new List<Student>{p2,p3};
IEnumerable<Person> e0 = new List<Person>{p1,p2,p3};
IEnumerable<Student> e1 = new List<Student>{p2,p3};
IEnumerable<Person> e2 = e1;
IEnumerable<Person> e3 = new List<Student>{p2,p3};
IList<Person> x = e2.ToList();
PrintNames(new List<Person>());
ICollection<Student> c1 = CreateStudents();
IEnumerable<Person> ec0 = CreateStudents();
IEnumerable<Student> ec1 = CreateStudents();
public static void PrintNames(ICollection<Person> persons)
Console.WriteLine(String.Join(Environment.NewLine, persons.Select(x => x.Name)));
public static ICollection<Student> CreateStudents()
return new List<Student>();
public string Name {get;set;}
public string Surname {get;set;}
public override string ToString() => $"{Name} {Surname}";
public class Student : Person
public string Id {get;set;}
public override string ToString() => $"Student {Id}: {Name} {Surname}";