System.Exception与System.SystemException [英] System.Exception vs System.SystemException

查看:56
本文介绍了System.Exception与System.SystemException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Exception与System.SystemException有什么区别

What is the difference between System.Exception vs System.SystemException

推荐答案

通常,SystemException保留供.NET运行时/框架使用,而不是您的应用程序代码.基本上,在创建自己的自定义Exception类时不要从SystemException派生.

A SystemException is usually reserved for the .NET runtime/framework to use, and not your application code. Basically, don't derive from SystemException when creating your own custom Exception class.

如果要创建自己的Exception类,则应该从Exception或ApplicationException派生它们.ApplicationException最初旨在用于非框架异常,但它已经被抛在了一边.我相信框架作者现在建议从基本Exception类派生自定义Exception.

If you are creating your own Exception classes, you should either derive them from Exception or ApplicationException. ApplicationException was originally intended to be used for non-framework exceptions, but it has sort of fallen to the wayside. I believe the framework authors now recommend to derive your custom Exceptions from the base Exception class.

这篇关于System.Exception与System.SystemException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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