-1

As you can see here I'm trying to assign a generic class instance to another generic class instance from different type T, but B inherits from A.

My logic says it must be able to be done, maybe I'm missing something.

abstract    class A
{    
}
class B : A
{            
}
class C<T> where T : A
{            
}

static void Main(string[] args)
{
    C<A> class1;
    C<B> class2;
    class1 = class2;
}
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

1 Answers1

-1

Its not possible ,only with implicit cast

        public static implicit operator C<T>(C<B> v)
        {

        }