title: How can I create a list of classes in C# to iterate over in a loop
body: <p>Suppose I have class <code>animal</code> and classes <code>cat</code> and <code>dog</code> extending it. I want to do something along the lines of:</p>
  
  <pre><code>foreach (class a in {cat, dog})  
      if (a.isValid(parameters))  
        doStuff();
  </code></pre>
  
  <p>isValid is a static method from animal that just checks if the given parameters define an object of the given type<br>
  doStuff means I'm doing stuff that I didn't feel was worth coppying over<br>
  @which objects are you talking about? hopefully my other edits clear this up<br>
  <strong>I'm not starting with an object and trying to determine it's type. I'm starting with parameters and trying to decide which animal type to instantiate as.</strong> So something like BlueRaja suggested, but without needing constructors.</p>
  
  <p>My only alternative is a switch statement for each class, something I'd like to avoid.</p>
  
  <p>Thanks,<br>
  J-B</p>