Question:
In Visual C# 2008, When I Write a Console Application, it doesn't pause...?
anonymous
2008-05-18 11:56:09 UTC
When I write a Console Application in C# 2008 and then press run and the CMD Screen shows up, and runs the program it runs it but it doesn't have the Press any key to continue and wait for me to press the any key to continue WTF...?

So far every Tutorial that I watched shows that there Console Applications let them press any key to continue... What gives, how come mines runs and it doesn't wait for me to press any key...?

Thanx...
Six answers:
anonymous
2008-05-18 13:05:35 UTC
To solve this problem heres what ya do...



Choose Debug in the menu bar on the top of the screen of your IDE for Visual C# 2008 or even VB 08 it does not matter...



Next Choose Start Without Debugging...



Volla, presto, it works and does the opisite of what it does when you just choose start debugging



CHOOSE : DEBUG > START WITHOUT DEBUGGING



Heres what you could do, either or one shows the Press any key to continue, and the other just runs it and exits...



DEBUG > START DEBUGGING, F5

"Does not show the press any key to continue"



DEBUG > START WITHOUT DEGUGGING, CTRL + F5

"Does show the press any key to continue"



Volla, Presto, ENJOY...
?
2016-05-25 08:56:58 UTC
Not sure I understand your question, but here's what I think you're saying. You're running your app thru debug, (or even if you double click) and the window for your program opens and closes. This happens because you have no breakpoints set (for debug) and no pauses. It just runs your program and exits. If you want to be able to look at your run (and I always do), open a command prompt window. Navigate to the Debug folder that has your executable. Enter the name and run the program that way. When the program exits, the window is still open and you can look at your output. Also, if you have an input file or a lot of output that you want to look at, you can pipe either or both an input and output filename to the executable.
JoelKatz
2008-05-18 12:07:01 UTC
You should run console applications from a console.
vagueship
2008-05-18 12:21:01 UTC
Not sure about c# (why would you do a console app in C#)



At the end of C++ you type getch();
Passionately Curious
2008-05-18 12:57:11 UTC
At the end of your code add:



Console.WriteLine("Press any key to continue");

Console.ReadKey();
Steven
2008-05-18 12:01:46 UTC
trying adding this to the end of code



system("pause");



let me know if this helps


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...