System.Environment.Exit does nothing when a button is clicked

I tried using:

Application.Exit();

and

Environment.Exit(0);

But from what I understand, the line that I have in my code is standard for closing the program, and this is what my teacher has in my code (this is how I build my project by copying my code for buttons and t .d.).

namespace atmproject
{
   public partial class form1welc : Form
   {
      //VARIABLES
      public static form1welc Welcome = new form1welc();
      public form1welc()
      {
         InitializeComponent();
      }

      private void welcexitbtn_Click(object sender, EventArgs e)
      {
         System.Environment.Exit(0);
      }

      private void welcloginbtn_Click(object sender, EventArgs e)
      {
         custlogin Customers = new custlogin();
         this.Hide();
         Customers.Show();
      }

      private void welcustbtn_Click(object sender, EventArgs e)
      {
         createcust Customers = new createcust();
         this.Hide();
         Customers.Show();
      }
   }
}
+4
source share
2 answers

You need to make sure that the Clickbutton event is “connected” to this method in the designer. If you click on the button in the designer, and then select the "Events" checkbox, you can choose a method for launching.

, , / , .

+6

-1,

System.Environment.Exit(-1);

, .

0

Source: https://habr.com/ru/post/1543316/


All Articles