Sorry if the name of the thread is unclear. I had no idea how to form it properly. Anyways.
I have a class.
Class Overflow {
public string Name;
public decimal MoneySpent;
public string Code;
}
Then I have an XML that has value
<Data>
<Name>John</LeidimoNr>
<MoneySpent>78621.25</Code>
<Code>XA-21456-sds</Code>
</Data>
So I need to put all of the XML values into the object Overflow.
What I'm doing is I'm iterating through Data
foreach (XPathNavigator val in it)
{
var name = val.Name;
var value = val.Value;
var Type = Overflow.GetType();
PropertyInfo info = Type.GetProperty(name);
info.SetValue(Overflow, value, null);
}
But the value is set to string and there's one value Decimal.
How do I make PropertyType same as in my class?