有没有的.NET异常类型何时使用它们的清单和建议? [英] Is there a list of .Net Exception types and advice on when to use them?
问题描述
有谁知道的.NET异常类型的列表中.eg ArgumentNullException
和在什么情况下,你要使用它们?目前,我只是猜测基于该类型的名字,但我更希望得到它的权利。
Does anyone know of a list of .Net Exception types .e.g. ArgumentNullException
and under what circumstances you should use them? At the moment I'm just guessing based on the type name but I would rather get it right.
推荐答案
它们的列表:
<一个href="http://mikevallotton.word$p$pss.com/2009/07/08/net-exceptions-all-of-them/">http://mikevallotton.word$p$pss.com/2009/07/08/net-exceptions-all-of-them/
至于的情况下,这取决于,大多数时候它们有意义基于其名称和参数。 ArgumentNullException
,例如,检查空值的方法/构造函数的参数时,通常使用。
As for the circumstance, it depends, most of the time they make sense based on their name and arguments. ArgumentNullException
, for example, is usually used when checking method / constructor arguments for null values.
然后你有其他的如 FileNotFoundException异常
,的NullReferenceException
, InvalidOperationException异常
,你可以看到他们阅读很容易,应该与普通意义上使用。
Then you have others such as FileNotFoundException
, NullReferenceException
, InvalidOperationException
, as you can see they read very easily and should be used with common sense.
更新1:有人曾建议,他们也MSDN上:
Update 1: as someone has suggested, they are also on MSDN:
<一个href="http://msdn.microsoft.com/en-us/library/system.exception.aspx#inheritanceContinued">http://msdn.microsoft.com/en-us/library/system.exception.aspx#inheritanceContinued
下面是常见的异常观点可供选择:
Here are views on common exceptions available:
<一个href="http://weblogs.asp.net/jgaylord/archive/2009/07/08/common-and-all-system-exceptions-in-net.aspx">http://weblogs.asp.net/jgaylord/archive/2009/07/08/common-and-all-system-exceptions-in-net.aspx
<一个href="http://www.developerfusion.com/article/1889/exception-handling-in-c/3/">http://www.developerfusion.com/article/1889/exception-handling-in-c/3/
更新2:作为的使用,微软有保留的异常类型准则:
Update 2: as for usage, Microsoft has guidelines for reserved exception types:
<一个href="http://msdn.microsoft.com/en-us/library/ms182338.aspx">http://msdn.microsoft.com/en-us/library/ms182338.aspx
这篇关于有没有的.NET异常类型何时使用它们的清单和建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!