New course! Every coder should learn Generative AI!
Try a free lesson0
Good day! How do I work with this in C #?
environment.exit()
6 Answers
+ 3
Thank you!
+ 2
Thank you! Very good explanation, but still there are numbers 1, 2 ... could you please tell me how they affect the exit from the program
+ 2
What do you mean with
Numbers 1 , 2
Please give more information
+ 2
environment.exit (1), environment.exit (2) is
+ 2
It is the return code that the application gives back to the operating system.
Just like return 0; in console applications.
0 is success, anything else indicates an error. There isn't a standard.
Some programs try to meet conventions.
https://stackoverflow.com/questions/11309675/what-are-the-default-values-that-can-be-passed-to-environment-exit-method
Here's Microsoft's conventions.
https://docs.microsoft.com/nl-nl/windows/win32/debug/system-error-codes--0-499-?redirectedfrom=MSDN
+ 1
This piece of code is closing the current application. This comes in handy when you want to have a Close/Exit button on your form. It works just like the cross in the upper right corner.