刚学c#不久,发觉c#中的输入语句不怎么好使。我现在只接触到Console.ReadLine(),但是如果是输入int型的时候,就必须用转换,很不方便。eg:int a,b; a=Convert.ToInt(ConSole.ReadLine()) //只用ConSole.ReadLine()就是错的 有没有简单的输入方法啊?为什么ConSole.ReadLine()不能直接付给int型变量啊?
调试欢乐多
从标准输入流读取下一行字符。返回值
类型:System..::.String输入流中的下一行字符;如果没有更多的可用行,则为 nullNothingnullptrnull 引用(在 Visual Basic 中为 Nothing)。给整型变量付值,只能转换一下了。再说你以后如果使用C#编程,一般不会开发控制台程序的。
a=convert.toint32(aa);
var b = Console.ReadLine();
//a = Convert.ToInt32(b);
a = int.Parse(b);
Console.Write("你的输入为" + a.ToString());
Console.ReadLine();
Console.Write("你的输入为" + a.ToString());
Console.ReadLine();
int a = Convert.ToInt32(Console.ReadLine());
//楼主掉了个32吧
int a = Convert.ToInt32(Console.ReadLine()):