How to exit a program with an exit code: C#

假装没事ソ 提交于 2019-12-22 04:18:11

问题


How to exit a program with an exit code in C#? In java it would be System.exit(int code);


回答1:


Either:

  • Declare your Main function as returning int, and return a value from it, or
  • Call Environment.Exit(int)

Returning a value from Main is a little nicer than exiting the process in the middle of a method, but this is presumably the same advice that applies to Java, C or C++.



来源:https://stackoverflow.com/questions/3529393/how-to-exit-a-program-with-an-exit-code-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!