ReflectorSetProperty(Object, PropertyInfo, Object, Object) Method

Sets a property represented by the specified PropertyInfo.

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public static void SetProperty(
	Object? instance,
	PropertyInfo property,
	Object? value,
	params Object?[]? indexParameters
)

Parameters

instance  Object
An instance whose property is about to be set. This parameter is ignored for static properties.
property  PropertyInfo
The property to set.
value  Object
The value to set.
indexParameters  Object
Index parameters if property is an indexer. This parameter is ignored for non-indexed properties.

Remarks

For setting the property this method uses the DynamicDelegate reflection way.

  Tip

To preserve the changes of a mutable value type embed it into a variable of Object type and pass it to the instance parameter of this method.

  Note

To set the property explicitly by dynamically created delegates use the PropertyAccessor class.

See Also