This documentation is archived and is not being maintained.

PropertyInfo.GetValue Method (Object, BindingFlags, Binder, Object[], CultureInfo)

.NET Framework 1.1

When overridden in a derived class, returns the value of a property having the specified binding, index, and CultureInfo.

[Visual Basic]
Overloads Public MustOverride Function GetValue( _
   ByVal obj As Object, _
   ByVal invokeAttr As BindingFlags, _
   ByVal binder As Binder, _
   ByVal index() As Object, _
   ByVal culture As CultureInfo _
) As Object
public abstract object GetValue(
 object obj,
 BindingFlags invokeAttr,
 Binder binder,
 object[] index,
 CultureInfo culture
public: virtual Object* GetValue(
 Object* obj,
 BindingFlags invokeAttr,
 Binder* binder,
 Object* index __gc[],
 CultureInfo* culture
) = 0;
public abstract function GetValue(
   obj : Object,
 invokeAttr : BindingFlags,
 binder : Binder,
 index : Object[],
 culture : CultureInfo
) : Object;


The object whose property value will be returned.
The invocation attribute. This must be a bit flag from BindingFlags: InvokeMethod, CreateInstance, Static, GetField, SetField, GetProperty, or SetProperty. A suitable invocation attribute must be specified. If a static member is to be invoked, the Static flag of BindingFlags must be set.
An object that enables the binding, coercion of argument types, invocation of members, and retrieval of MemberInfo objects via reflection. If binder is a null reference (Nothing in Visual Basic), the default binder is used.
Optional index values for indexed properties. This value should be a null reference (Nothing in Visual Basic) for non-indexed properties.
The CultureInfo object that represents the culture for which the resource is to be localized. Note that if the resource is not localized for this culture, the CultureInfo.Parent method will be called successively in search of a match. If this value is a null reference (Nothing in Visual Basic), the CultureInfo is obtained from the CultureInfo.CurrentUICulture property.

Return Value

The property value for obj.


Exception Type Condition
ArgumentException The index array does not contain the type of arguments needed.


The property's Get method is not found.

TargetException The object does not match the target type, or a property is an instance property but obj is a null reference (Nothing in Visual Basic).
TargetParameterCountException The number of parameters in index does not match the number of parameters the indexed property takes.
MethodAccessException There was an illegal attempt to access a private or protected method inside a class.


Because static properties belong to the type, not individual objects, get static properties by passing a null reference (Nothing in Visual Basic) as the object argument. For example, use the following code to get the static CurrentCulture property of CultureInfo:

PropertyInfo CurCultProp = (typeof(CultureInfo)).GetProperty("CurrentCulture");

Console.WriteLine("CurrCult: " + CurCultProp.GetValue(null,null));

To use the GetValue method, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, use the GetValue method.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

PropertyInfo Class | PropertyInfo Members | System.Reflection Namespace | PropertyInfo.GetValue Overload List | Binder | BindingFlags | CultureInfo