I use reflection to get FieldInfos in a class and assign to them with FieldInfo.SetValue. It works fine when i assign primitive types (i use Convert.ChangeType to convert from object to type) but doesn't work if the field is an array. It works if i use Array.Cast but the type is only known at runtime so i cant cast. I saw lots of topics on this but none of them worked so far.
I get this exception:
ArgumentException: Object type System.Object[] cannot be converted to target type: System.Single[]
I know why it happens i just can't find a way to convert the data. Any ideas?
Aucun commentaire:
Enregistrer un commentaire