c#如何使用READLINE读取输入并用INT32中PARSE换为整数,最后转化为字符输出

写个例子,谢

Console.WriteLine("请输入数字:");
string input = Console.ReadLine();
try
{
int i = int.Parse(input);
Console.WriteLine("输入的数字为:" + i.ToString());
}
catch
{
Console.WriteLine("输入字符为非数字");
}
Console.ReadKey();
在一楼的基础上加上try...catch,锦上添花
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-05-04
Console.WriteLine("请输入数字!");
string s = Console.ReadLine();
int i = int.Parse(s);
Console.WriteLine(s.ToString());
Console.ReadKey();

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网