1,
Int N;
String STR = "XXX ";
If (Int. tryparse (STR, out n ))
{
// Number
}
Else
{
// Non-numeric
}
2,
1. String PAT = @ "[\ u4e00-\ u9fa5]";
RegEx Rg = new RegEx (PAT );
Match MH = RG. Match (textbox1.text );
If (MH. Success)
{
// It is a Chinese character
}
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)
{
// It indicates that the character is not a number.
Return 0;
}
}
// The description is a number.
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 = new RegEx ("[^ 0-9]");
Return! RegEx. ismatch (strnumber );
}
System. Text. regularexpressions. RegEx reg1 = new system. Text. regularexpressions. RegEx (@ "^ [-]? \ D + [.]? \ D * $ ");
If (reg1.ismatch (STR ))
{
// Number
}
Else
{
// Non-numeric
}