Есть задача:
public class A { }
public class A1 : A { }
public class A2 : A { }
public class B<T> where T : A { }
public class B1 : B<A1> { }
public class B2 : B<A2> { }
public class Conteiner<T, U> where T : B<U> where U : A
{
T[] list;
public T this[int index]
{
get { return list[index]; }
set { list[index] = value; }
}
public void Set<K, N, M>(K conteiner)
where K : Conteiner<N, M>
where N : B<M>
where M : A
{
list[0] = conteiner[0]; <------Ошибка не удается преобразовать тип N в T.
}
}
Как решить или обойти проблему?
можно обойтись делая так:
public class Conteiner<T, U> where T : B<U> where U : A
{
T[] list;
public T this[int index]
{
get { return list[index]; }
set { list[index] = value; }
}
public void Set<K,N,M>(Conteiner<T, U> conteiner)
where K : Conteiner<N, M>
where N : B<M>
where M : A
{
list[0] = conteiner[0];
}
}
Современные инструменты для криптотрейдинга: как технологии помогают принимать решения
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости