我想定义一个扩展方法,它递归到嵌套结构,你猜对了,异常.这就是我想做的......
class Utils
{
public static string TellMeEverything(this Exception ex)
{
return ex.InnerException?.TellMeEverything() + ex.Message + ex.StackTrace;
}
}
Run Code Online (Sandbox Code Playgroud)
但是这会产生编译器错误 'Exception' does not contain a definition for 'TellMeEverything' and no extension method 'TellMeEverything' accepting a first argument of type 'Exception' could be found (are you missing a using directive or an assembly reference?)
这可能被视为编译器错误吗?