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);
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);
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

调用属性。 这必须是来自 BindingFlags 的位标志:InvokeMethodCreateInstanceStaticGetFieldSetFieldGetPropertySetProperty。 必须指定合适的调用属性。 如果要调用静态成员,则必须设置 BindingFlagsStatic 标志。

binder
Binder

一个对象,它使用反射启用绑定、参数类型的强制、成员的调用和 MemberInfo 对象的检索。 如果 bindernull,则使用默认联编程序。

index
Object[]

索引化属性的可选索引值。 对于非索引化属性,该值应为 null

culture
CultureInfo

表示要为其本地化资源的区域性的 CultureInfo 对象。 请注意,如果没有为此区域性本地化该资源,则在搜索匹配项的过程中将继续调用 CultureInfo.Parent 方法。 如果此值为 null,则从 CultureInfo.CurrentUICulture 属性获得 CultureInfo

例外

不支持此方法。

注解

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

适用于