什么是创造我自己的自定义异常的最佳做法? [英] What are some best practices for creating my own custom exception?
问题描述
在后续到的以前就问题例外,什么是在.NET中创建一个自定义异常的最佳做法?
In a follow-up to a previous question regarding exceptions, what are best practices for creating a custom exception in .NET?
更具体地说,你应该从System.Exception,System.ApplicationException或其他一些基本异常继承?
More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception?
推荐答案
从 System.Exception的
继承。 System.ApplicationException
是无用和设计指南说的不要投掷或从 System.ApplicationException $ c中衍生出$ C>。
Inherit from System.Exception
. System.ApplicationException
is useless and the design guidelines say "Do not throw or derive from System.ApplicationException
."
请参阅的 http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx
这篇关于什么是创造我自己的自定义异常的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!