0

在 Script# 中,是否可以定义自己的异常类?我不能从 Exception 派生,因为它是密封的:

public class MyException : Exception {} // Cannot inherit from sealed class Exception

如果我尝试抛出一个不从 Exception 继承的异常,我会得到另一个错误:

Error   22  The type caught or thrown must be derived from System.Exception

似乎没有对此的支持?

4

1 回答 1

1

这是不可能的。

您无法在生成的脚本中捕获特定类型。如果你有额外的数据想要放在异常中,那么 Exception 类型有成员来保存额外的数据。

于 2013-06-30T23:11:51.630 回答