Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 views
in Technique[技术] by (71.8m points)

c# - Reading console input in MonoDevelop

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}

The program is:

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

This is enclosed in a class called 'MainClass'

Its output is:

What is your name?
Your name is:

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

alt text http://psf.biz/public/monodevelop_run_on_external_console.jpg

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...