There is a program in which some data is entered. How to make the program close when entering incorrect data?
2 answers
To complete the process, use Environment.Exit .
|
You need to throw an exception, like:
throw new Exception("Пипец всему!");
Or just
void Main(){ //твой код if (error) return; }
- What is the minus? Answer on the topic, everything works. - Balsoft
- What is the exception? It does not close the program at all. - Pavel Mayorov
- Oh damn, I completely forgot - Balsoft
- It just stops the execution of the program, isn't that necessary? - Balsoft
- 6The thrown exception is accepted to be caught and processed. And during processing, the same problem arises - how to shut down the program. That's why I say - the exception has nothing to do with it, the program is closed with no exception. - Pavel Mayorov
|