【问题标题】:I'm having issues makin a simple input and output program我在制作一个简单的输入和输出程序时遇到问题
【发布时间】:2016-11-12 01:51:41
【问题描述】:

好的,所以当我想放这条线时,我会使用 Visual c#

enter code here




static void Main(string[] args)
        {
            Console.ReadLine a, b, c, max;

        }
    }
}

但它说有关 ReadLine 部分的此错误​​: “Console”类型中不存在类型名称“ReadLine”

【问题讨论】:

  • 我该怎么办?
  • 看起来您已经在Java 中提出了同样的问题。你在这里的最终目标是什么?两个都学?
  • @Rahul 那是很久以前的事了,我没有认真学习 Java,但我正在学习这个更认真的东西,而且你很固执 xD ;)
  • 谁能告诉我如何使用这个命令来处理整数?我想要一个程序来获取数字并告诉你哪个更高我只需要输入部分的帮助。
  • 您需要将数据转换为INT类型。开始阅读文档...通过提出没人会学的问题。

标签: c# visual-c#-express-2010


【解决方案1】:

Console.ReadLine 是一个方法,所以应该这样使用:

Console.WriteLine("Enter something"); //this will print the text to the screen
string inputText = Console.ReadLine(); // Get string from the input and assign it to the inputText variable

你可以看到一个额外的参考here

【讨论】:

    【解决方案2】:

    这是什么???先去阅读 MSDN 文档。错误是因为 ReadLine() 是一种方法,但您正试图将它本身用作一种类型。假设您已经声明了一个名为 a 的变量并且它的类型为 string,它应该在下面。

    a = Console.ReadLine();
    

    阅读Console.ReadLine Method ()。文档中很少有很好的例子可以帮助您消除疑虑。

    【讨论】:

    • @user3607864,如果有帮助,请考虑接受答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-10
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多