System.Convert for basic types.
Simplified code