New with c#

M

Martin VavpotiÄ

Hello. I have recently begun to program with c#. I've done some
programming with Java before so I'm not a total noob but I do have
some questions.

I use Textpad to compile the code and that generates an .exe file.
When I double-click that or use Run option of Windows, I see a MS Dos
Prompt for a milisecond. I need to make the Prompt Window to stay open
until I close it. How do I do that?
 
R

Registered User

Hello. I have recently begun to program with c#. I've done some
programming with Java before so I'm not a total noob but I do have
some questions.

I use Textpad to compile the code and that generates an .exe file.
When I double-click that or use Run option of Windows, I see a MS Dos
Prompt for a milisecond. I need to make the Prompt Window to stay open
until I close it. How do I do that?

static void Main(string[] args)
{
....
// put a prompt to the console
Console.WriteLine("\n\tHit any key to exit");
// wait for the any key
while (Console.ReadKey() == null) ;
}

regards
A.G.
 
A

Arne Vajhøj

Hello. I have recently begun to program with c#. I've done some
programming with Java before so I'm not a total noob but I do have
some questions.

I use Textpad to compile the code and that generates an .exe file.
When I double-click that or use Run option of Windows, I see a MS Dos
Prompt for a milisecond. I need to make the Prompt Window to stay open
until I close it. How do I do that?

static void Main(string[] args)
{
....
// put a prompt to the console
Console.WriteLine("\n\tHit any key to exit");
// wait for the any key
while (Console.ReadKey() == null) ;
}

Just:

Console.ReadKey();

should be fine.

ReadKey is blocking.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Wonderful opinionated book on C# 16
Starting C# 1
New to C# 6
Beginning C# 1
Getting Started With C# 12
C# projects 2
Desktop movement streaming to LAN 3
Changing the function keys (ctrl,alt shift) F1..F12 3

Top