c# - 从 main 中抛出异常的 C# 程序的退出代码是什么?

标签 c#

在 C# 程序中,main 抛出异常时定义的退出代码是什么?我知道您可以通过多种方式设置退出代码,如 this excellent answer 中所述。 .但令我感到非常惊讶的是,当从 main 中抛出异常时,我无法找到关于退出代码的 值被定义为 的文档。是否有一个标准来定义在这种情况下退出代码的值,或者它是否取决于操作系统(或机会,或其他任何东西)?

最佳答案

我观察到 -532462766

PS C:\Projects\Throw\Throw\bin\Debug> .\Throw.exe

Unhandled Exception: System.Exception: Exception of type 'System.Exception' was thrown at Throw.Program.Main(String[] args) in c:\Projects\Throw\Throw\Program.cs:line 13

PS C:\Projects\Throw\Throw\bin\Debug> $LASTEXITCODE
-532462766

关于c# - 从 main 中抛出异常的 C# 程序的退出代码是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43195148/

相关文章:

c# - 如何将自定义字符串解析为 DateTime C#?

c# - 在 C# 2.0 中将 Dictionary<string,List<foo>> 转换为 List<foo>

c# - 如何使用 C# 从服务器获取打印机详细信息

c# - 从 Excel 单元格中的超链接文本中提取 URL

c# - 使用 C# 实现 EDI X12

c# - 如何反编译 .net framework 的 IL 代码

c# - 枚举需要索引吗?

c# - 如何在C#中获取机器的IP地址

c# - 使用数据绑定(bind)从 UI 更改数据

c# - LINQ to NHibernate,如何做这个查询