If you want to keep it open for debugging purposes, you'll need to instruct the computer to wait for a key press before ending the app and closing the window. The Console.ReadLine method is one way of doing that. ![]() Something like: #if DEBUGĬonsole.WriteLine("Press enter to close.") The best compromise is probably to call the Console.ReadLine method only when debugging the application by wrapping it in a preprocessor directive.Īdding this line to the end of your code (just before the return statement) will cause the application to wait for you to press a key before exiting.Īlternatively, you could start the application without the debugger attached by pressing Ctrl+ F5 from within the Visual Studio environment, but this has the obvious disadvantage of preventing you from using the debugging features, which you probably want at your disposal when writing an application. To do that you can put the Console.ReadLine() in a finally block: #if DEBUG You might also want the window to stay open if an uncaught exception was thrown. ![]() If you want to keep your application opened, you have to do something in order to keep its process alive.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |