当属性是委托类型时,如何使用C#中的反射设置属性值? [英] How to set the property value using reflection in C# when the property is a delegate type?
问题描述
我在一个dll中有一个属性,我在C#中使用反射功能。我想设置属性,属性类型是委托类型。
请让我知道使用Reflection设置属性所涉及的步骤。
我知道需要使用SetValue方法来执行此操作,但不知道如何设置委托类型的属性。
SetValue(objectName,1,null)是使用反射设置整数属性,但不知道如何设置委托类型的属性。
如何声明委托属性类型的变量并使用反射对其进行初始化?
请提供示例解决方案。
$
谢谢,
I have a property in a dll that i am using using Reflection feature in C#. I would like to set the property and the property type is a delegate type.
Please let me know the steps involved in setting the property using the Reflection.
I know that SetValue method need to be used to do this, but don't know how to set the property of the delegate type.
SetValue(objectName, 1, null) is to set an integer property using reflection, but don't know how to set the property of the delegate type.
How to declare a variable of the delegate property type and initialize it using reflection?
Please provide solution with an example.
Thanks,
Raghu Devisetti
Raghu Devisetti
|