The purpose of this is to synchronize two collections, sender-side & receiver-side, containing a graph edge, so that when something happens (remove edge, add edge, etc)
Eric Lippert said that C# will only support type-safe covariance and contravariance. If you would think of it, making ICollection
covariant is not type-safe.
Let's say you have
ICollection dogList = new List();
ICollection mammalList = dogList; //illegal but for the sake of showing, do it
mammalList.Add(new Cat());
Your mammalList
(which is actually a dogList
) would now then contain a Cat
.
IEnumerable
is covariant because you cannot Add
to it... you can only read from it -- which, in turn, preserves type-safety.