Argentini.Halide.H3Config.GetKeyAsInt32 C# (CSharp) Method

GetKeyAsInt32() public static method

Retrieve the value of an application setting from the Web.config file.
public static GetKeyAsInt32 ( String keyName, Int32 defaultValue, String sectionName ) : Int32
keyName String Key name for which a value should be returned.
defaultValue System.Int32 Default value to use if the key is not found.
sectionName String Section name within the Web.config file.
return System.Int32
        public static Int32 GetKeyAsInt32(String keyName, Int32 defaultValue, String sectionName)
        {
            NameValueCollection settings = (NameValueCollection)ConfigurationManager.GetSection(sectionName);
            Int32? value = null;

            if (settings[keyName] != null)
            {
                if (H3Identify.IsPureNumeric(settings[keyName].ToString()))
                {
                    value = Convert.ToInt32(settings[keyName]);
                }
            }

            if (value == null)
            {
                value = defaultValue;
            }

            return (Int32)value;
        }

Same methods

H3Config::GetKeyAsInt32 ( String keyName, Int32 defaultValue ) : Int32
H3Config::GetKeyAsInt32 ( String keyName, String defaultValue ) : Int32
H3Config::GetKeyAsInt32 ( String keyName, String defaultValue, String sectionName ) : Int32
H3Config::GetKeyAsInt32 ( String keyName ) : Int32?