The ReportingEmployeesIds = {2345, 432, 521}
doesn't set the property. It is shorthand for calling Add(...)
with each of the items. You can always Add
, even for a readonly list property.
For it to be a set it would need to be:
ReportingEmployeesIds = new List<int> {2345, 432, 521}
Instead, the line:
Manager m = new Manager {Name = "Dave", ReportingEmployeesIds = {2345, 432, 521} }
is essentially:
var m = new Manager();
m.Name = "Dave";
var tmp = m.ReportingEmployeesIds;
tmp.Add(2345);
tmp.Add(432);
tmp.Add(521);