How to exit an application in C# and VB.NET

To exit an application in C# and VB.NET you can use the following snippet.

Sample C#

System.Windows.Forms.Application.Exit(0); // WINFORM
Environment.Exit(0); // CONSOLE APP
Application.Shutdown(); // WPF

Sample VB.NET

System.Windows.Forms.Application.[Exit](0) ' WINFORM
Environment.[Exit](0) ' CONSOLE APP
Application.Shutdown() ' WPF

2 thoughts on “How to exit an application in C# and VB.NET

Leave a Reply