解决方案 »

  1.   

     a < (int)a + 1e-9 && a > (int)a - 1e-9
      

  2.   


      /// <summary>
        /// 判断一个字符串是否为合法整数(不限制长度)
        /// </summary>
        /// <param name="s">字符串</param>
        /// <returns></returns>
        public static bool IsInteger(string s)
        {
            string pattern = @"^\d*$";
            return Regex.IsMatch(s, pattern);
        }
      

  3.   

            public static Boolean IsInteger(String str)
            {
                for (Int32 i = 0; i < str.Length; i++)
                {
                    if (!Char.IsDigit(str[i]))
                        return false;
                }            return true;
            }
            static void Main(string[] args)
            {
                String str = "124341241234321a";            Console.WriteLine(IsInteger(str));
            }   
      

  4.   

    试试下面这段代码!
    public static bool ifNumber(object sNum, out long outint)
      {
       if (sNum == null)
       {
        outint = 0;
        return false;
       }
       if (long.TryParse(sNum.ToString(), out outint))
        return true;
       else
        return false;
      }
      

  5.   

    /// <summary>
            /// 是否是整数,空返回false
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public static bool IsInt(string str)
            {
                if (str == string.Empty)
                    return false;
                try
                {
                    Convert.ToInt32(str);
                    return true;
                }
                catch
                {
                    return false;
                }
            }
      

  6.   

    比如32.00就应该为true,32.11为false
      

  7.   

    bool a = int.TryParse("32.00", out aa);
    怎么是false啊
      

  8.   


    Console.WriteLine("30.12: " + ((30.12).ToString().IndexOf(".")>=0 ? "false" : "true"));
                Console.ReadKey();
      

  9.   

    Convert.ToInt32看是否会出现异常,有异常则不是整数,没有异常时整数。或用正则表达式。
      

  10.   

                int fnum = 0;    
                if (!int.TryParse(“要判断的字符串”, out fnum))
                    {
                        Response.Write("<script language=javascript>alert('文本域行数请输入正整数!')</script>");
                        return;
                    }
      

  11.   

    onkeypress="checkNumber();"
            function checkNumber()
            {
              if(!(((window.event.keyCode>=48)&&(window.event.keyCode<=57))||(window.event.keyCode==13)))
               {
                    window.event.keyCode=0;
               }
            }
    只能输入正整数
      

  12.   

    告诉你个笨办法!! 你先把要判断的数字 装换成字符串 然后用LastIndexOf()方法来查询该字符串中是否有 . 即可!!!西西 解决问题的办法有很多 希望对楼主有帮助!!
      

  13.   

    怎么还有人用try..catch这种方法?