There is a task:
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. } } How to solve or work around a problem?
Set:public void Set(Conteiner<T, U> conteiner). Otherwise, it is simply impossible, since you can haveU=A1, andM=A2and these types are not given - Andrey NOPConteiner<T, U>and then writing thereConteiner<N, M>. What problem are you trying to solve? - tym32167