Esempio n. 1
0
        /// <summary>
        /// object转int
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>错误-1</returns>
        public static int SafeToInt(object obj)
        {
            int val = -1;

            int.TryParse(SafeConverter.SafeToString(obj), out val);
            return(val);
        }
Esempio n. 2
0
        public static bool SafeToBool(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            bool val = false;

            bool.TryParse(SafeConverter.SafeToString(obj), out val);
            return(val);
        }