PropertyBuilder.GetValue 方法

定义

通过调用 getter 获取属性的值。

重载

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

通过调用属性的 getter 方法获取索引属性的值。

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

获取具有指定绑定、索引和 CultureInfo. 的属性的值。

GetValue(Object, Object[])

通过调用属性的 getter 方法获取索引属性的值。

public:
 override System::Object ^ GetValue(System::Object ^ obj, cli::array <System::Object ^> ^ index);
public override object GetValue(object obj, object[] index);
override this.GetValue : obj * obj[] -> obj
Public Overrides Function GetValue (obj As Object, index As Object()) As Object

参数

obj
Object

将返回其属性值的对象。

index
Object[]

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

返回

指定的索引属性的值。

例外

不支持此方法。

注解

若要获取属性的值,请使用 Type.GetType 或 Assembly.GetType 反映属性的父类型,从类型中检索 Reflection 属性对象,然后调用 PropertyInfo.GetValue

适用于

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

获取具有指定绑定、索引和 CultureInfo. 的属性的值。

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

参数

obj
Object

将返回其属性值的对象。

invokeAttr
BindingFlags

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

binder
Binder

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

index
Object[]

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

culture
CultureInfo

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

返回

的属性值 obj

例外

不支持此方法。

注解

若要获取属性的值,请使用 Type.GetType 或 Assembly.GetType 反映属性的父类型,从该类型中检索 Reflection 属性对象,并调用 PropertyInfo.GetValue。

适用于