First, the general parameter TObject is defined in Class1. This TObject is used in Class1 as a type argument in MethodA.
In Class2, the TObject passed to the base (Class1) is class 2, so lambda can output the local _propertyInt property.
In Class3, the TObject passed to the base is Class2, not Class3. Therefore, the lambda argument is deduced, but it is deduced as Class2, not Class3.
The fact that Class2 also has a type parameter named TObject is completely the same, I think you expect that everything that is passed to this TObject will be transitively passed to Class1, but it is not.
If you defined Class3 as follows, it will work:
public class Class3 : Class1<Class3> { ... }
Given the comment, I can suggest this solution based on the extension method (assuming that the type parameters are only intended to do the job):
public class Class1 { } public static class StaticClass1 { public static void MethodA<TZen, TType>(this TZen zen, Expression<Func<TZen, TType>> property, ref TType store, TType value) where TZen : Class1 {
source share