When should one use Environment.Exit to terminate a console application?

前端 未结 7 1356
长发绾君心
长发绾君心 2020-12-03 06:58

I\'m maintaining a number of console applications at work and one thing I\'ve been noticing in a number of them is that they call Environment.Exit(0).

A sample progr

7条回答
  •  -上瘾入骨i
    2020-12-03 07:29

    Basically the statement Environment.Exit(0) tells the Operating system that this is a "clean" exit. There are other numbers as well each with a different meaning like Environment.Exit(1)

    However one thing to note is that the "Main" has been declared as returning nothing "void", so the exit code will really not have a meaning to it.

    Just in case you wanted to know more about the different exit codes have a look here

    system Error Codes

提交回复
热议问题