如何退出一个程序,退出code:C# [英] How to exit a program with an exit code: C#

查看:176
本文介绍了如何退出一个程序,退出code:C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何退出,退出code在C#程序? 在java中这将是<一href="http://download.oracle.com/javase/1.4.2/docs/api/java/lang/System.html#exit%28int%29"><$c$c>System.exit(int code);

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

推荐答案

或者:

  • 声明你的函数返回 INT ,并从它返回一个值,或
  • 呼叫<一href="http://msdn.microsoft.com/en-us/library/system.environment.exit.aspx"><$c$c>Environment.Exit(int)
  • Declare your Main function as returning int, and return a value from it, or
  • Call Environment.Exit(int)

返回从的值比退出过程中的方法的中间更好一点,但是这是presumably适用于Java的同样的忠告,C或C ++。

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++.

这篇关于如何退出一个程序,退出code:C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆