Cannot convert from List<Bar> to List<Foo>

Viewed 4282

I have a set up like this:

abstract class Foo {}
class Bar : Foo {}

and a method elsewhere of this form:

void AddEntries(List<Foo>) {}

I am trying to call this method using a list of objects of type Bar

List<Bar> barList = new List<Bar>()
AddEntries(barList);

but this gives me the error:

cannot convert from List<Bar> to List<Foo>

Is there anyway around this problem? I Need to keep the method definition using the abstract class.

3 Answers
Related