If you use a universal extension method for a universal class, is there a better way? Since it would be natural to call func2 exactly as func1<V>() , rather than func2<T, V>() , that is, omit the parameter T and name it as func2<V>()
public class A<T> where T : class { public V func1<V>() { //func1 has access to T and V types } } public static class ExtA { // to implement func1 as extension method 2 generic parameters required // and we need to duplicate constraint on T public static V func2<T, V>(this A<T> instance) where T : class { // func2 has access to V & T } }
source share