It just came to attention that every time we run the c# console application, at the end it shows text stating "Press any key to continue... ".
And the moment you hit any key, it terminates the console/program. In actual program there is no mentioning about such text printing on standard output console, then from where and why it comes out on screen?
Can someone explain the logic behind?
Code:
static void Main(string[] args)
{
Console.WriteLine("Test Application");
}
Output:
Test Application
Press any key to continue . . .
It has nothing to do with your application itself. When you double-click on the output EXE file you'll not see it. It is only when we run the app from within Visual Studio without the debugger attached when this behavior is seen.
When you press Ctrl+F5, Visual Studio is running your app in a way that causes the console window to remain open.
I think it comes from cmd parameters that are used. Something like :
%COMSPEC% /k "C:\VS\MyApplication.exe"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With