ReflectorTryGetIndexedMember(Object, ReflectionWays, Object, Object) Method

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

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public static bool TryGetIndexedMember(
	Object instance,
	ReflectionWays way,
	out Object?? value,
	params Object?[] indexParameters
)

Parameters

instance  Object
An instance to be set.
way  ReflectionWays
The preferred reflection way. TypeDescriptor way is not applicable here. This parameter is ignored for arrays.
value  Object
When this method returns with result, then this parameter contains the value returned by the indexable object.
indexParameters  Object
The index parameters.

Return Value

Boolean
, if the indexed member could be read; , if a matching property or array getter could not be found.

Remarks

This method ignores explicitly implemented interface properties.

  Note

If a matching indexed property could be found and the invocation itself has thrown an exception, then this method also throws an exception instead of returning .

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

If way is Auto, then this method uses the DynamicDelegate reflection way.

See Also