I have 2 types, IFoo, and Foo defined as
public interface IFoo
{
void run()
}
public class Foo : IFoo
{
public void run() {
// ...
}
}
I am able to assign a List<Foo> to an IEnumerable<IFoo>, but not an ICollection<IFoo> nor an IList<IFoo>.
IEnumerable<IFoo> fooEnumerable = new List<Foo>();// works fine
ICollection<IFoo> fooCollection = new List<Foo>();// doesn't work
IList<IFoo> fooList = new List<Foo>();// doesn't work
Why is that? What allows an IEnumerable to not care about what type it's comprised of, while ICollection and IList do care?