在MonoDevelop中读取控制台输入 [英] Reading console input in MonoDevelop

查看:155
本文介绍了在MonoDevelop中读取控制台输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试一个简单的C#程序,该程序接受输入并将其作为输出传递.例如,输出应为:

I am trying to a simple C# program that takes input and passes it as output. For instance, the output should be:

What is your name?
{user input}
Your name is {user input}

程序为:

public static void Main(string[] args)
{
    Console.WriteLine("What is your name?");
    string name = Console.ReadLine();
    Console.WriteLine("Your name is: " + name);
    Console.ReadKey();
}

这包含在名为"MainClass"的类中

This is enclosed in a class called 'MainClass'

其输出是:

What is your name?
Your name is:

为什么这不起作用,我如何使其起作用?

Why is this not working and how can I make it work?

P.S.我正在使用MonoDevelop,并添加了Console.ReadKey();.在最后一个WriteLine之后.没变化.

P.S. I am using MonoDevelop and I added Console.ReadKey(); after the last WriteLine. No change.

推荐答案

您正试图在MonoDevelop中的应用程序输出"窗口中键入内容,并且它是只读的.

You are trying to type in the Application Output window in MonoDevelop and it is read-only.

通过右键单击项目的选项"菜单项并选中Run > General树下的Run on external console,可以将MonoDevelop配置为在命令提示符下自动运行程序.

You can configure MonoDevelop to automatically run the program at the command prompt by right clicking on the "options" menu item of your project and checking Run on external console under the Run > General tree.

替代文本http://psf.biz/public/monodevelop_run_on_external_console.jpg

我想给我-1的那个家伙被那个巨大的在我的机器上工作"标志遮住了,尽管如此,这是唯一正确的答案.

I guess the guy that gave me the -1 was blinded by that huge "Works on My Machine" emblem, nevertheless this is the correct and only answer.

这篇关于在MonoDevelop中读取控制台输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆