PropertyBuilder.SetValue 方法

定义

将给定对象的属性值设置为给定值。

重载

名称 说明
SetValue(Object, Object, Object[])

使用索引属性的可选索引值设置属性的值。

SetValue(Object, Object, BindingFlags, Binder, Object[], CultureInfo)

将给定对象的属性值设置为给定值。

SetValue(Object, Object, Object[])

使用索引属性的可选索引值设置属性的值。

public:
 override void SetValue(System::Object ^ obj, System::Object ^ value, cli::array <System::Object ^> ^ index);
public override void SetValue(object obj, object value, object[] index);
override this.SetValue : obj * obj * obj[] -> unit
Public Overrides Sub SetValue (obj As Object, value As Object, index As Object())

参数

obj
Object

将设置其属性值的对象。

value
Object

此属性的新值。

index
Object[]

索引属性的可选索引值。 此值应 null 适用于非索引属性。

例外

不支持此方法。

注解

若要设置属性的值,请反映属性 Type.GetType 的父类型,或者 Assembly.GetType,从该类型中检索 PropertyInfo 对象,然后调用 PropertyInfo.SetValue

适用于

SetValue(Object, Object, BindingFlags, Binder, Object[], CultureInfo)

将给定对象的属性值设置为给定值。

public:
 override void SetValue(System::Object ^ obj, System::Object ^ value, System::Reflection::BindingFlags invokeAttr, System::Reflection::Binder ^ binder, cli::array <System::Object ^> ^ index, System::Globalization::CultureInfo ^ culture);
public override void SetValue(object obj, object value, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] index, System.Globalization.CultureInfo culture);
override this.SetValue : obj * obj * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo -> unit
Public Overrides Sub SetValue (obj As Object, value As Object, invokeAttr As BindingFlags, binder As Binder, index As Object(), culture As CultureInfo)

参数

obj
Object

将返回其属性值的对象。

value
Object

此属性的新值。

invokeAttr
BindingFlags

调用属性。 这必须是来自 BindingFlagsInvokeMethod、、、StaticCreateInstanceGetFieldSetFieldGetProperty或的SetProperty位标志。 必须指定合适的调用属性。 如果要调用静态成员, Static 则必须设置该标志 BindingFlags

binder
Binder

一个对象,它允许绑定、强制参数类型、调用成员以及使用反射检索 MemberInfo 对象。 binder如果是null,则使用默认绑定器。

index
Object[]

索引属性的可选索引值。 此值应 null 适用于非索引属性。

culture
CultureInfo

表示 CultureInfo 要为其本地化资源的区域性的对象。 请注意,如果此区域性的资源未本地化, CultureInfo.Parent 则会在搜索匹配项时连续调用该方法。 如果为此值 null,则 CultureInfoCultureInfo.CurrentUICulture 属性中获取该值。

例外

不支持此方法。

注解

若要设置属性的值,请反映属性 Type.GetType 的父类型,或者 Assembly.GetType,从该类型中检索 PropertyInfo 对象,然后调用 PropertyInfo.SetValue

适用于