I have a problem with a set of generic types.
For example, I have classes:
public class Dog
{
}
public class Husky : Dog
{
}
public class MyWrapper<T> where T : class
{
}
and then I want to do something like that, but I don’t know how
MyWrapper<Husky> husky = new MyWrapper<Husky>();
List<MyWrapper<Dog>> dogs= new List<MyWrapper<Dog>>();
dogs.Add(husky);
EDIT: changed Animal<T>to MyWrapper<T>, so this would be a more suitable example
source
share