使用 linq 表达式动态属性设置器?
我想创建一个简单的函数来执行以下操作:
Sub SetValue(Of TInstance As Class, TProperty)(
ByVal instance As TInstance,
ByVal [property] As Expression(Of Func(Of TInstance, TProperty)),
ByVal value As TProperty)
'...
End Sub
用法:
Dim x As New Person
SetValue(x, Function(p) p.FirstName, "John Doe")
I want to create a simple function that does the following:
Sub SetValue(Of TInstance As Class, TProperty)(
ByVal instance As TInstance,
ByVal [property] As Expression(Of Func(Of TInstance, TProperty)),
ByVal value As TProperty)
'...
End Sub
Usage:
Dim x As New Person
SetValue(x, Function(p) p.FirstName, "John Doe")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
其实很简单:
HTH
It's actually pretty simple:
HTH