Extension Methods

Possible duplicate:
ArgumentNullException or NullReferenceException from extension method?

So, I know that extension methods are just syntactic sugar for static helper methods, so you can happily (?) Call them null objects and will not automatically get a NullReferenceException.

My question is, should you, as the developer of the extension method, manually throw a NullReferenceException in the extension method so that it works as much as possible as a native method. Or should you do something more ordinary and throw an ArgumentNullException?

I think this is a style issue, and I would prefer the latter option, but wondered how far people think you should go when extension methods look and act like their own methods.

+3
source share

Source: https://habr.com/ru/post/1795436/


All Articles