C# 例外清单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11376829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
list of exceptions
提问by Pavani gaddam
I am looking for a list of possible exceptions in c#, c++, vb.net, j# and jscript. The problem is that some sites show me a list of 20 exceptions whereas some other site shows me a list of 39 exceptions. Can anyone please give me a proper information on this?
我正在寻找 c#、c++、vb.net、j# 和 jscript 中可能的异常列表。问题是某些站点向我显示了 20 个例外的列表,而其他一些站点向我显示了 39 个例外的列表。任何人都可以给我一个正确的信息吗?
回答by Jon Skeet
There are loadsof exceptions declared by the .NET framework - and other code (including your own) can create more. There are certainly more than 39.... look at the documentation for System.Exceptionand you'll see near the bottom a list of all the directknown subclasses just in the .NET framework.
有负载由.NET Framework宣布例外-和其他代码(包括你自己)就能创造更多。肯定有超过 39 个......查看文档System.Exception,您将在底部附近看到.NET 框架中所有直接已知子类的列表。
Basically, it's not useful to know "all the exceptions" - what's important is which exceptions can be thrown by code you are executing, and in particular which exceptions you should really try to handle (rather than those which should either kill the process or just make the request fail in a server environment).
基本上,了解“所有异常”是没有用的 - 重要的是您正在执行的代码可以抛出哪些异常,特别是您应该真正尝试处理哪些异常(而不是那些应该杀死进程或只是在服务器环境中使请求失败)。
回答by 48klocs
If you're looking for a list of exceptions that the .Net framework can throw, this article has a bunch of them. I don't know where you're pulling those specific numbers from and I don't know what you hope to accomplish by knowing all of the exceptions (including ones you'll likely never see).
如果您正在寻找 .Net 框架可以抛出的异常列表,这篇文章有很多。我不知道您从哪里提取这些具体数字,也不知道您希望通过了解所有例外(包括您可能永远不会看到的例外)来完成什么。

