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 NullReferenceException, if I try to use a member of e inside TakeRandom(), NullReferenceException will be thrown anyway.
Maybe I should peak using Reflector and find out what the framework does.