c# shutdown application code example

Example 1: how to exit a program in c#

Application.Exit();

Example 2: shutdown system C#

Process.Start("shutdown","/s /t 0");

Example 3: c# how to exit program

System.Environment.Exit(1);

Example 4: shutdown system C#

var psi = new ProcessStartInfo("shutdown","/s /t 0");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);
// to avoid creating window

Example 5: c# program exit

System.Windows.Forms.Application.ExitThread( )