0
public interface IRandom {}    
public class Random: IRandom {}

I can assign:

IRandom random = new Random();

but when I try this:

IList<IRandom> randomList = new List<Random>();

I get cannot convert List<Random> to target type IList<IRandom>

Can someone please explain why not?

Basically I was trying to have a list I could assign another list to which contain items that inherited from IRandom.

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
user2005657
  • 607
  • 10
  • 20

0 Answers0