//
验证是否为整数数字
public
static
bool
IsValidInt(
string
strIn,
int
intFrom,
int
intTo,
bool
bolSign)

...
{
string strSign;
if (bolSign)
strSign = @"(+|-)?";
else
strSign = string.Empty;

if(intFrom < 0 && intTo < 0)
return Regex.IsMatch(strIn, @"^" + strSign + "[0-9]*$");
else if(intFrom >= 0 && intTo >= 0)
return Regex.IsMatch(strIn, @"^" + strSign + @"d{" + intFrom.ToString() + "," + intTo.ToString() + "}$");
return false;
}


//
验证是否为浮点数字
public
static
bool
IsValidDecimal(
string
strIn,
int
Integer,
int
DecimalLength,
bool
bolSign)

...
{
string strSign;
if (bolSign)
strSign = @"(+|-)?";
else
strSign = string.Empty;

return Regex.IsMatch(strIn, @"^" + strSign + @"(d{0," + Integer.ToString() + @"})?(.d{0," + DecimalLength.ToString() + "})?$");
}