创建自己的自定义异常的最佳做法是什么? [英] 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
。
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屋!
查看全文