我正在从Python转向C#,但在使用ReadLine()
函数方面遇到了麻烦。如果我想要询问用户输入,我在Python中会这样做:
x = int(input("Type any number: "))
在C#中,这变成了:
int x = Int32.Parse (Console.ReadLine());
但是,如果我输入这个,就会出现错误:
int x = Int32.Parse (Console.ReadLine("Type any number: "));
我该如何在C#中要求用户输入内容?
Console.WriteLine()
,然后再使用Console.ReadLine()
。 - PikohConsole.Write("Type any number:");
或者Console.WriteLine
然后你可以进行读取行操作。 - pinkfloydx33