以下是引用ruffianshen在2007-4-26 11:33:28的发言:
搞定,呵呵!<BR>像你那种太麻烦了,我找资料写了一个方法<BR><BR> public static string IsNumber(string str)<BR> {<BR> if (str.Trim() == "")<BR> return "0";<BR> ...
using System.Text.RegularExpressioin;
public static string IsNumber(string str)
{
if (str.Trim() == "")
return "0";
else
{
if (Regex.IsMatch(str, @"^[+-]?\d+[\.]?\d*$"))
{
return str;
}
else
return "0";
}
}