tags:

views:

31

answers:

1

check this out

Type configPropType = configurableProp.getPropertyType();
string attValue = xmlelement.GetAttribute(configurableProp.getName());
configProps[configurableProp.getName()] = attValue;

At the point where I am setting the value that got read in from XML it turns out the assigning object needs to be parsed to the correct type for it to work. I need something like.

configProps[configurableProp.getName()] = configPropType.ParseToThisType(attValue);

Looked around on msdn but its a very confusing place.

+2  A: 

Looks like what you are trying to do is accomplished with something along these lines:

configProps[configurableProp.getName()] =
        Convert.ChangeType(attValue, configPropType);
Guido Domenici
perfect. here is a challenge, without knowing that - what search terms would find you the answer on msdn?
DrLazer
I wouldn't use search terms - I'd learn the .NET Framework basics, which would include the `Convert` class. I'd also learn how properties work in .NET, so my code would look like `configurableProp.Name` instead of `configurableProp.getName()`
John Saunders
That was helpfull John. I am specifically using functions to get things i dont want saving to XML and reserving the public Getters to save data reflectively. Unfortunately we don't all have the time to be 46k+
DrLazer