while (playerIsAlive) { // this code will keep running if (playerIsAlive == false) { // eventually if this stopping condition is true, // it will break out of the while loop break; } } // rest of the program will continue
// In a console application: Environment.Exit(0); // In a WPF application: Close();
Use "break;" for (int i = 1; i <= 100; i++) { if (i == 5) { break; } }
System.Windows.Forms.Application.ExitThread( )