how can I create a list of classes in C3 to itterate over in a loop

Posted by Jean-Bernard Pellerin on Stack Overflow See other posts from Stack Overflow or by Jean-Bernard Pellerin
Published on 2010-05-06T21:34:54Z Indexed on 2010/05/06 21:38 UTC
Read the original article Hit count: 374

Filed under:
|
|

example:
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();
(couldn't get the code formatting to work)

my only alternative is a switch statement for each class, something I'd like to avoid

Thanks,
J-B

© Stack Overflow or respective owner

Related posts about c#

Related posts about class