When you do:
obj.Thresholds[i] = value;
that is semantically equivalent to:
double[] tmp = obj.Thresholds;
tmp[i] = value;
which means you don't want a SetValue
at all; rather, you want to use GetValue
to obtain the array, and then mutate the array. If the type is known to be double[]
, then:
double[] arr = (double[]) pi.GetValue(myObject, null);
arr[i] = value;
otherwise perhaps the non-generic IList
approach (since arrays implement IList
):
IList arr = (IList) pi.GetValue(myObject, null);
arr[i] = value;
If it is a multi-dimensional array, you'll have to use Array
in place of IList
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…