I have a question, how was the decision for these 2 classes ctor parameters made...
Constructor for ArgumentNullException
public ArgumentNullException( string paramName, string message)
Constructor for ArgumentException
public ArgumentException( string message, string paramName)
Well, in short Jeff, this was a design mistake. In fact it is up on the internal “API Design Hall of Shame”. Here is the text from that site:
ArgumentNullException does not follow the constructor pattern given in the Design Guidelines spec.
Result: Habit wins out and people commonly type:
throw new ArgumentNullException (“must pass an employee name”);
throw new ArgumentNullException (“Name”, “must pass an employee name”);
so we end up with error message such as:
Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: must pass employee name
Lesson: Just follow the pattern!
Got any other examples that should be in my API Design Hall of Shame?