Why does the below code throw compile error? As per C# 4.0 Covariance should'nt such a conversion be allowed. List employeeList = managerList;
class Program
{
static void Main(string[] args)
{
List<Manager> managerList = new List<Manager>()
{
new Manager{ FirstName="ASFD", LastName="DSS", NoOfReportees=4},
new Manager{ FirstName="rrr", LastName="dsasde", NoOfReportees=22}
};
List<Employee> employeeList = managerList;
}
}
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class Manager:Employee
{
public int NoOfReportees { get; set; }
}