CTCClassSchedule.Common.Miscellaneous.SafeNameValueToInt32 C# (CSharp) Method

SafeNameValueToInt32() public static method

public static SafeNameValueToInt32 ( this nameValues, string paramName, int defaultValue ) : int
nameValues this
paramName string
defaultValue int
return int
        public static int SafeNameValueToInt32(this NameValueCollection nameValues, string paramName, int defaultValue)
        {
            if (nameValues.AllKeys.Contains(paramName))
            {
                int outValue;
                if (int.TryParse(nameValues[paramName], out outValue))
                {
                    return outValue;
                }
            }
            return defaultValue;
        }