You can use a workaround: Define a method for each type that you want to support
private static Add(float a, float b) {return a+b;} private static Add(double a, double b) {return a+b;} ...
and create a delegate for the correct at runtime:
MethodInfo addMethod=this.GetType().GetMethod("Add",BindingFlags.NotPublic|Static,null,new Type[2]{typeof(T),typeof(T)},null); Func<T,T,T> addFunction=(Func<T,T,T>)Delegate.CreateDelegate(typeof(Func<T,T,T>),addMethod);
Zotta
source share