What is the error message you get when Magic has a class constraint:
public ISomeInterface Magic<T>(Func<object> a, decimal d) where T:class
This may be better worded, but when he says: "T must be a reference type ...", it actually means that "T is class-limited." This code generates the same error as the OP:
class ABC { public ISomeInterface DoMagic<T>(Expression<Func<object>> action, Tuple<string, DateTime, decimal> tuple) where T : ISomeInterface { Magician m = new Magician(); return m.Magic<T>(() => action, tuple.Item3); } } interface ISomeInterface { } class Magician { public ISomeInterface Magic<T>(Func<object> a, decimal d) where T:class { throw new NotImplementedException(); } }
The type ' T ' must be a reference type in order to use it as a parameter ' T ' in the generic type or method ' ConsoleApplication4.Magician.Magic<T>(System.Func<object>, decimal) '
source share