How can I create a list of classes in C# to iterate over in a loop
- by Jean-Bernard Pellerin
Suppose I have class animal and classes cat and dog extending it. I want to do something along the lines of:
foreach (animal a in {cat, dog})
if (a.isValid(parameters))
doStuff();
My only alternative is a switch statement for each class, something I'd like to avoid.
Thanks,
J-B