I have a Type, a String and an Object.
Is there some way I can call the parse method or convert for that type on the string dynamically?
Basically how do I r
This should work for all primitive types, and for types that implement IConvertible
public static T ConvertTo(object value)
{
return (T)Convert.ChangeType(value, typeof(T));
}
EDIT : actually in your case, you can't use generics (not easily at least). Instead you could do that :
object value = Convert.ChangeType(myString, propType);