阅读背景:

扩展方法的ArgumentNullException或NullReferenceException?

来源:互联网 

What would you consider to be the best exception type to throw when an extension method is called on a null instance (where the extension method does not allow it)? Since extension methods are nothing but static methods you could argue that it should be ArgumentNullException, but on the other hand they're used like instance methods so it might be more natural to use the NullReferenceException. Let's take the following example:What would you consider to be the best exceptio




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: