几在C# 中,用什么方法可以判断1段字符串是否全为数字?是不是用正规表达式啊?怎样写啊? 在C# 中,用什么方法可以判断1段字符串是否全为数字?例如: string str1 = "123456";string str2 = "123456asdfg";是不是用正规表达式啊?怎样写啊?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private bool Check( string value){ try { Decimal a = System.Decimal.Parse(value) ; return true ; } catch { }} private bool Check( string value){ try { Decimal a = System.Decimal.Parse(value) ; return true ; } catch { return false ; }}刚才没写完....按错键了. 正则:using System.Text.RegularExpressions; ......string str;......bool yn=Regex.IsMatch(str,@"^\d+$");if(yn==true) { MessageBox.Show("y"); //含有数字}else{ MessageBox.Show("n"); //不含有数字} 在属性生成器里拉出Regularexpressionvalidat,在ValidationExpression里添加 [0-9]+ bool check=Regex.IsMatch(str,@"^\d+$"); 求教,怎么做到绑定数据读一条处理一条? 一个登陆界面,大家帮忙看看哪里错了,郁闷啊! 网站日志中有一些奇怪的东西,不知是不是遭人攻击了 ExecuteQuery与ExecuteDataset的区别? 在查询大量数据时,各位是用什么方法实现 做三层结构的菜单可采取那些方法? 急救,再线等,马上给分!!!!! 设定ASP.NET页面5分钟刷新一次,请教示例 请教有关treeview递归绑定的速度优化 如何让Web窗体中的Label控件可以自动换行 如何将dataset表中的字段分别邦定到textbox控件 2个头疼的问题,asp.net将IE缩到系统托盘,谁有ASP写的类似QQ的即时通讯器???
{
try
{
Decimal a = System.Decimal.Parse(value) ;
return true ;
}
catch
{
}
}
{
try
{
Decimal a = System.Decimal.Parse(value) ;
return true ;
}
catch
{
return false ;
}
}
刚才没写完....按错键了.
if(yn==true)
{ MessageBox.Show("y"); //含有数字
}
else
{
MessageBox.Show("n"); //不含有数字}