C#: Best practice for validating “this” argument in extension methods
问题 Let's say I have an extension method public static T TakeRandom<T>(this IEnumerable<T> e) { ... To validate the argument e, should I: A) if (e == null) throw new NullReferenceException() B) if (e == null) throw new ArgumentNullException("e") C) Not check e What's the consensus? My first thought is to always validate arguments, so thrown an ArgumentNullException. Then again, since TakeRandom() becomes a method of e, perhaps it should be a NullReferenceException. But if it's a