Why, with the general restriction on a parameter of type T of class P "should inherit from A", is the first call made, but the second call ends with the type conversion error indicated in the comment:
abstract class A { }
static class S
{
public static void DoFirst(A argument) { }
public static void DoSecond(ICollection<A> argument) { }
}
static class P<T>
where T : A, new()
{
static void Do()
{
S.DoFirst(new T());
S.DoSecond(new List<T>());
}
}
Should a general restriction ensure that List<T> really ICollection<A>?
source
share