Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to override virtual generic method by replacing some or all of type parameters?

Tags:

c#

Is there a way to override virtual generic method by replacing some or all of type parameters with actual type arguments?

class A1
{
    public virtual void Generic<T, U>(T t, U u) { }
}

class A2 : A1
{
    public override void Generic<T,int>(T t, int u) { } //error
}

thanx

like image 949
user702769 Avatar asked Dec 13 '22 13:12

user702769


1 Answers

Try moving the generic parameters to class.

    class A1<T,U>
    {
        public virtual void Generic(T t, U u) { }
    }

    class A2<T> : A1<T , int>
    {      
        public override void  Generic(T t, int u) { }
    }
like image 71
Bala R Avatar answered Jan 18 '23 23:01

Bala R