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.
public static void SetProperty(
Object instance,
string propertyName,
bool ignoreCase,
Object? value,
params Object?[]? indexParameters
)
Public Shared Sub SetProperty (
instance As Object,
propertyName As String,
ignoreCase As Boolean,
value As Object,
ParamArray indexParameters As Object()
)
public:
static void SetProperty(
Object^ instance,
String^ propertyName,
bool ignoreCase,
Object^ value,
... array<Object^>^ indexParameters
)
static member SetProperty :
instance : Object *
propertyName : string *
ignoreCase : bool *
value : Object *
indexParameters : Object[] -> unit
propertyName can refer public and non-public properties. To avoid ambiguity (in case of indexers), this method gets all of the properties of the same name and chooses the first one for which the provided indexParameters match.
If you already have a PropertyInfo instance use the SetProperty(Object, PropertyInfo, Object, ReflectionWays, Object) method for better performance.
If you are not sure whether a property with the specified propertyName exists, then you can use the TrySetProperty methods instead.
For setting the property this method uses the TypeDescriptor way for ICustomTypeDescriptor implementations and the DynamicDelegate way otherwise.