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

前端 未结 7 1361
长发绾君心
长发绾君心 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条回答
  •  渐次进展
    2020-12-03 07:15

    I'm currently using Environment.Exit() in a console app where I don't want to throw ugly exception text back to the console. Instead I just notice the condition, write a user friendly message to the screen about what happened and then call Environment.Exit().

    Otherwise, you shouldn't need to call it from Main() in a basic console application.

提交回复
热议问题