C# 异常
C#异常处理
基本
1 |
|
- 可以
catch
很多不同的异常,不指定的话默认Exception,即捕获所有异常
throw抛出异常
主动抛出异常
比如在自己的类中,用if
判断是否由奇奇怪怪的错误,然后抛出,再去调用申明好的自定义或预定义的异常类
Exception类
.net
预定义的异常的基类
自定义异常类
推荐的格式,带3个构造函数
1 |
|
- 和
throw
配套使用,不然异常类就没有用
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.