/// <summary> /// Casts the object to the System.Double /// </summary> /// <param name="sourceObj">The source object</param> public static double?CastNullableDouble(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseDouble(stringValue)); } catch (FormatException) { return(default(double?)); } default: return(sourceObj.AsDouble()); } }
public static double CastDouble(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseDouble(stringValue)); } catch (FormatException) { return(default(double)); } default: return(sourceObj.AsDouble()); } }