'Why can't I instantiate a child class on its parent Generic Interface?

I have the following arrangement:

public interface Inter<T>{}


public class Child : Inter<int> {}

When I try to instantiate Child like this:

Inter<object> a = new Child();

The compiler complains that it can't convert Child into Inter< object>.

However, if I try the following:

IEnumerable<object> list = new List<string>();

It works just fine.

The question is, why the first instantiation throws a Conversion Error and the second doesn't?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source