Exemple #1
0
        public static int ToInt32(object input, int defaultValue)
        {
            string temp = Wf_ConvertHelper.ToString(input);

            if (string.IsNullOrEmpty(temp))
            {
                return(defaultValue);
            }

            if (Wf_RegexHelper.IsInt(temp))
            {
                return(System.Convert.ToInt32(input));
            }
            else
            {
                return(defaultValue);
            }
        }
Exemple #2
0
        public static short ToInt16(object input, short defaultValue)
        {
            string temp = Wf_ConvertHelper.ToString(input);

            if (Wf_StringHelper.IsNullOrEmptyByTrim(temp))
            {
                return(defaultValue);
            }

            if (Wf_RegexHelper.IsInt(temp))
            {
                return(System.Convert.ToInt16(temp));
            }
            else
            {
                return(defaultValue);
            }
        }