什么是创造我自己的自定义异常的最佳做法? [英] What are some best practices for creating my own custom exception?

查看:137
本文介绍了什么是创造我自己的自定义异常的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在后续到的以前就问题例外,什么是在.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆