Direct from SHanselman, as pointed by Cristi Diaconescu, but I've included the main source code:
public static T GetTfromString(string mystring)
{
var foo = TypeDescriptor.GetConverter(typeof(T));
return (T)(foo.ConvertFromInvariantString(mystring));
}
The whole article deserves a closer look!