I need help creating common parameters before the interface.
I have a prebaked code like this:
public interface InterFoo<T> {...}
public InterFoo<T> specialFoo<T>() where T : InterFoo<T> {...}
public InterFoo<T> regularFoo<T>() {...}
and I want to implement something like this
public InterFoo<T> adaptiveFoo<T>()
{
if (T is InterFoo<T>)
return specialFoo<T as InterFoo>();
return regularFoo<T>();
}
at this moment I cannot find any solution so that everything is useful, thanks.
EDIT: initially the functions returned int, but it has a simpler solution incompatible with the purpose of the code, the functions have been changed to request a common type.
source
share