c# 判断字符串是否为数字

时间:2014-11-05 16:51:19   收藏:0   阅读:172

float floattemp=0;

float.TryParse(kf, out floattemp) true则是数字,false则不为数字

控制小数点位数

 strLength = floattemp.ToString().Split(‘.‘);

strTemp = strLength[1];
if (strTemp.Length > 2)
{
err += "高考总分小数点后部分超过2位;";
}

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!