I'm using Reflection to load some values from an XML into a structure. All works but I got a problem to manage the array. With an Int32 it's ok, but how can I manage an Int32[]?
//My structure
public struct stMyStruct
{
public int Number;
public int[] Numbers;
}
//My function
public T MyFunction<T>()
{
Type type = typeof(T);
var returnObject = Activator.CreateInstance(type);
List<Settings> list = null;
//List "list" is populated with my value, in example Number = 3
foreach (Settings entry in list)
{
FieldInfo field = returnObject.GetType().GetField(entry.Key.ToString());
field.SetValue(returnObject, Convert.ToUInt32(entry.Value.ToString()));
}
}
I am confused. But I hope I have been clear asking my question.
Aucun commentaire:
Enregistrer un commentaire