O
ORC
I will use FieldInfo to import values from a XML file into the fields of an
objects. But how to convert to the proper type like in this:
public void Load(object MyClass)
{
foreach( FieldInfo field in MyClass.GetType().GetFields() )
{
field.SetValue(MyClass,
String_From_XML_Representing_The_Field_Value);
}
}
The SetValue method doesn't automatically convert to the correct type and
therefore raises an error, so how do I do that?
Mvh
Ole
objects. But how to convert to the proper type like in this:
public void Load(object MyClass)
{
foreach( FieldInfo field in MyClass.GetType().GetFields() )
{
field.SetValue(MyClass,
String_From_XML_Representing_The_Field_Value);
}
}
The SetValue method doesn't automatically convert to the correct type and
therefore raises an error, so how do I do that?
Mvh
Ole