C# 检查数字

        #region 检查数字
        public bool IsNumeric(string value)
        {
            bool result;
            try
            {
                int x = int.Parse(value);
                result = true;
            }
            catch
            {
                result = false;
            }

            try
            {
                double x = double.Parse(value);
                result = true;
            }
            catch
            {
                result = false;
            }

            try
            {
                float x = float.Parse(value);
                result = true;
            }
            catch
            {
                result = false;
            }

            return result;
        }
        #endregion

 

posted @ 2019-03-12 15:04  芈璐  阅读(168)  评论(0编辑  收藏  举报