Creating a property setter delegate

前端 未结 4 572
误落风尘
误落风尘 2020-11-30 22:23

I have created methods for converting a property lambda to a delegate:

public static Delegate MakeGetter(Expression> propertyLam         


        
4条回答
  •  再見小時候
    2020-11-30 22:54

    Action represents a delegate that takes one parameter of type T and returns nothing. The lambda expressions you provide to MakeSetter represent delegates that take no parameter and return either SomeClass.SomeProperty or someObject.SomeProperty.

    The error messages you're getting are due to the fact that the compiler cannot infer the types from the lambda expressions you're passing into the MakeSetter method because what you've passed and what the method is expecting are not in sync.

提交回复
热议问题