以下是代码片段:
Int32price;
if(Int32.TryParse(textBox1.Text,
System.Globalization.NumberStyles.Integer,
System.Globalization.NumberFormatInfo.CurrentInfo,outprice))
...{
//输入为数字
MessageBox.Show(price.ToString());
}
else
MessageBox.Show("输入错误");
代码主要演示了TryParse的用法,实际上,对于C#来说,每个数据类型都有相应的方法,用起来很方便。
C# TryParse 方法实战
2万+

被折叠的 条评论
为什么被折叠?



