Share via


SetValue Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Sets the property value of a specified object with optional index values for index properties.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overridable Sub SetValue ( _
    obj As Object, _
    value As Object, _
    index As Object() _
)
public virtual void SetValue(
    Object obj,
    Object value,
    Object[] index
)
public:
virtual void SetValue(
    Object^ obj, 
    Object^ value, 
    array<Object^>^ index
)
abstract SetValue : 
        obj:Object * 
        value:Object * 
        index:Object[] -> unit 
override SetValue : 
        obj:Object * 
        value:Object * 
        index:Object[] -> unit 
public function SetValue(
    obj : Object, 
    value : Object, 
    index : Object[]
)

Parameters

  • index
    Type: array<System. . :: . .Object> [] () [] []
    Optional index values for indexed properties. This value should be nullNothingnullptrunita null reference (Nothing in Visual Basic) for non-indexed properties.

Remarks

If this PropertyInfo object is a value type and value is null Nothing nullptr unit a null reference (Nothing in Visual Basic) , then the property will be set to the default value for that type.

To determine whether a property is indexed, use the GetIndexParameters method. If the resulting array has 0 (zero) elements, the property is not indexed.

This is a convenience method that calls the runtime implementation of the abstract SetValue(Object, Object, BindingFlags, Binder, array<Object>[]()[][], CultureInfo) method, specifying BindingFlags..::..Default for the BindingFlags parameter, null Nothing nullptr unit a null reference (Nothing in Visual Basic) for Binder, and null Nothing nullptr unit a null reference (Nothing in Visual Basic) for CultureInfo.

To use the SetValue method, first get a Type object that represents the class. From the Type, get the PropertyInfo. From the PropertyInfo, use the SetValue method.

.NET Framework Security

See Also

Reference

PropertyInfo Class

System.Reflection Namespace