public static GetDoubleValue ( this config, string name, Double defaultValue ) : double | ||
config | this | The available configuation values. |
name | string | The name of the setting to retrieve. |
defaultValue | Double | The default in case the named /// value does not exist. |
Résultat | double |
public static double GetDoubleValue( this NameValueCollection config,
string name, Double defaultValue )
{
if (config == null)
return defaultValue;
string val = config[name];
if (val == null)
return defaultValue;
val = val.Trim();
if (val.Length == 0)
return defaultValue;
try
{
return Double.Parse(val);
}
catch (Exception)
{
throw new ArgumentOutOfRangeException(name, val,
string.Format("'{0}' must be a double value.", name));
}
}