title: ArgumentException vs. ArgumentNullException?
body: <p>I’m refactoring some code and adding a method which will replace a (soon-to-be) deprecated method.  The new method has the following signature:</p>
  
  <pre><code>FooResult Foo(FooArgs args) { ... }
  </code></pre>
  
  <p>The deprecated method contained a growing list of parameters.  These parameters are now properties on the <code>FooArgs</code> class.  The deprecated method has several guard conditions which checked for null values with the following structure:</p>
  
  <pre><code>if (parameter1 == null)
      throw new ArgumentNullException(“parameter1”);
  if (parameter... == null)
      throw new ArgumentNullException(“parameter...”);
  if (parameterN == null)
      throw new ArgumentNullException(“parameterN”);
  </code></pre>
  
  <p>Now that the parameters have been collapsed into the <code>FooArgs</code> class should I throw an <strong>ArgumentNullException</strong> for the individual properties of the <code>FooArgs</code> parameter:</p>
  
  <pre><code>if (args.Property1 == null)
      throw new ArgumentNullException(“args.Property1”);
  if (args.Property... == null)
      throw new ArgumentNullException(“args.Property...”);
  if (args.PropertyN == null)
      throw new ArgumentNullException(“args.PropertyN”);
  </code></pre>
  
  <p>Or to throw a more general <strong>ArgumentException</strong> for the <strong>entire</strong> <code>FooArgs</code> parameter:</p>
  
  <pre><code>if (args.Property1 == null)
      throw new ArgumentException(“Property1 cannot be null.”, “args”);
  if (args.Property... == null)
      throw new ArgumentException(“Property... cannot be null.”, “args”);
  if (args.PropertyN == null)
      throw new ArgumentException(“Property2 cannot be null.”, “args”);
  </code></pre>
  
  <p>Thanks!</p>