The Convert class will help:

value = (T)Convert.ChangeType(rawValue, typeof(T))

Fascinating. I've not noticed that method before. The MSDN doco says that
ChangeType expects an IConvertible, which int, double, long, etc do.

It turns out I couldn't use a TypeConverter because I'm in Silverlight.

I can't use ChangeType in my case either, but I will stick that in my head
for future use. I have to parse strings that are coming in a decimal number
strings and also as 0xnnnnn hex number strings. Sadly I had to use
reflection to get the Parse method and invoke it on the string after I have
tweaked it.

Greg

 

Reply via email to