Candor.Configuration.Provider.ProviderHelperExtensions.GetDoubleValue C# (CSharp) Method

GetDoubleValue() public static method

A helper method to get an double value from a configuration setting value.
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.
return 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));
            }
        }