二进,八进,十进进都可以用
try{
Decimal t=Decimal.Parse(str)
return true;
}catch{
return false;
}
那十六进呢??
十六进制的数字写法都有几种,那怎么验证?C#里面有没有自带的方法?就像上面x.Parse之类的???
try{
Decimal t=Decimal.Parse(str)
return true;
}catch{
return false;
}
那十六进呢??
十六进制的数字写法都有几种,那怎么验证?C#里面有没有自带的方法?就像上面x.Parse之类的???
{
return System.Text.RegularExpressions.Regex.IsMatch(s, "^[0-9A-Fa-f]+$");
}
{
try
{
ulong.Parse(s, System.Globalization.NumberStyles.HexNumber);
return true;
}
catch (FormatException)
{
return false;
}
}