I\'m studying C# by following the guides in MSDN.
Now, I just tried the Example 1 (here is the link to MSDN), and I\'ve encountered an i
This behaves the same for CtrlF5 or F5.
Place immediately before end of Main
method.
using System.Diagnostics;
private static void Main(string[] args) {
DoWork();
if (Debugger.IsAttached) {
Console.WriteLine("Press any key to continue . . .");
Console.ReadLine();
}
}
Use Console.Read(); to prevent the program from closing, but make sure you add the Console.Read();
code before return statement, or else it will be a unreachable code .
Console.Read();
return 0;
check this Console.Read
Add the following before the return 0:
system("PAUSE");
This prints a line to hit a key to close the window. It will keep the window up until you hit the enter key. I have my students add it to all their programs.