ReflectorSetIndexedMember(Object, Object, Object) Method

Sets the value of an indexable object. It can be either an array instance or an object with default members (indexed properties).

Definition

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

Parameters

instance  Object
An instance to be set.
value  Object
The value to set.
indexParameters  Object
The index parameters.

Remarks

This method ignores explicitly implemented interface properties.

If you already have a PropertyInfo instance of the indexed property, then use the SetProperty(Object, PropertyInfo, Object, ReflectionWays, Object) method for better performance.

For setting an indexed property this method uses the DynamicDelegate reflection way, except when the .NET Standard 2.0 version of the KGySoft.CoreLibraries assembly is referenced and the indexer belongs to a value type (struct), in which case the SystemReflection way will be used.

  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.

See Also