PropertyAccessorSet(Object, Object, Object) Method
Sets the property.
For static properties the instance parameter is omitted (can be ).
If the property is not an indexer, then indexParameters parameter is omitted.
Namespace: KGySoft.ReflectionAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
public void Set(
Object? instance,
Object? value,
params Object?[]? indexParameters
)
Public Sub Set (
instance As Object,
value As Object,
ParamArray indexParameters As Object()
)
public:
void Set(
Object^ instance,
Object^ value,
... array<Object^>^ indexParameters
)
member Set :
instance : Object *
value : Object *
indexParameters : Object[] -> unit
Parameters
- instance Object
- The instance that the property belongs to. Can be for static properties.
- value Object
- The value to set.
- indexParameters Object
- The parameters if the property is an indexer.
Setting the property for the first time is slower than the System.Reflection.PropertyInfo.SetValue
method but further calls are much faster.
The method can be use also for ref properties.
If the property has no more than one index parameters and you know the type of the property at compile time
(and also the declaring type for instance properties), then you can use the generic
SetStaticValue
or
SetInstanceValue methods for better performance.
If the property is an instance property of a value type, then the .NET Standard 2.0 version of this method defaults to use regular reflection
to preserve mutations. To experience the best performance try to target .NET Standard 2.1 or any .NET Framework or .NET Core/.NET platforms instead.