public static object ConvertTo(this object value, Type type) { Contract.ArgumentNotNull("type", type); return(System.Convert.ChangeType( value, type)); }
public static bool TryConvertTo(Type type, object originalObj, out object convertedObj) { Contract.ArgumentNotNull("type", type); convertedObj = null; try { convertedObj = System.Convert.ChangeType( originalObj, type); return(true); } catch (Exception) { } return(false); }