1、
int n;
string str="xxx";
if(int.TryParse(str,out n))
{
   //为数字
}
else
{
 //非数字
}

2、
1、string mailto:pat=@%22[\u4e00-\u9fa5]";
Regex rg=new Regex(pat);
Match mh=rg.Match(textBox1.Text);
if(mh.Success)
{
 //是汉字
}
2、function fucCheckNUM(NUM)
{
var i,j,strTemp;
strTemp="0123456789.";
if ( NUM.length== 0)
return 0
for (i=0;i<NUM.length;i++)
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//说明有字符不是数字
return 0;
}
}
//说明是数字
return 1;
}






void bool CheckNUM(string str)
{
           if(str==string.Empty||string==null)
             retrun false;
          try
            {
                decimal.Parse(str)
             }
        catch
          {
             return false; 
          }
          return true;
}






public static bool IsNumber(string strNumber)
{
    Regex regex = new Regex("[^0-9]");
    return !regex.IsMatch(strNumber);
}






System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[-]?\d+[.]?\d*$");
         
if(reg1.IsMatch(str))
{
//数字
}
else
{
//非数字
}




///
   /// 判断是否是数字
   ///
   /// 字符串
   ///
   private bool IsNumeric(string str)
   {
    if (str == null || str.Length == 0)
     return false;
    System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
    byte[] bytestr = ascii.GetBytes(str);
    foreach(byte c in bytestr)
    {
     if (c < 48 || c > 57)
     {
      return false;
     }
    }
    return true;
   }

//判断是否为数字
public static bool StrIsInt(string Str)
{
try
{
Int32.Parse(Str);
return true;
}
catch
{
bool flag = false;
return flag;
}
}

 

posted on 2009-07-22 02:25  阿C's  阅读(1230)  评论(0)    收藏  举报