示例#1
0
        /// <summary>
        /// Returns true if the object is a number, false otherwise. Note that we also have an extension method for the string class that does the same thing.
        /// </summary>
        /// <remarks>http://stackoverflow.com/questions/437882/what-is-the-c-sharp-equivalent-of-nan-or-isnumeric</remarks>
        /// <param name="value"></param>
        /// <returns></returns>
        public static Boolean isNumeric(object value)
        {
            String strValue = SafeConvert.SafeString(value, "NaN");

            if (strValue == "NaN" || strValue == "Infinity")
            {
                return(false);
            }

            long myNum = 0;

            return(long.TryParse(strValue, out myNum));
        }