3

Possible Duplicate:
C# - Is there a better alternative than this to ‘switch on type’?

1.) http://channel9.msdn.com/forums/TechOff/411739-switch-objectGetType-/?CommentID=411995

2.) http://blogs.msdn.com/jaredpar/archive/2008/05/16/switching-on-types.aspx

3.) Or is there an even better way....?

Please reflect both on speed and ease of reading the code.

Community
  • 1
  • 1
thomas nn
  • 933
  • 3
  • 13
  • 21
  • see also http://stackoverflow.com/questions/156467/switch-pattern-matching-idea http://stackoverflow.com/questions/7252186/switch-case-on-type-c-sharp http://stackoverflow.com/questions/7542793/how-to-use-switch-case-on-a-type http://stackoverflow.com/questions/4478464/c-sharp-switch-on-type http://stackoverflow.com/questions/298976/c-sharp-is-there-a-better-alternative-than-this-to-switch-on-type – Mikhail Poda May 01 '12 at 11:58
  • and http://stackoverflow.com/questions/94305/what-is-quicker-switch-on-string-or-elseif-on-type http://stackoverflow.com/questions/6304815/why-is-this-switch-on-type-case-considered-confusing http://stackoverflow.com/questions/5947343/how-to-switch-between-possible-type-of-an-object http://stackoverflow.com/questions/10115028/best-way-to-switch-behavior-based-on-type – Mikhail Poda May 01 '12 at 11:58

1 Answers1

1

Of all suggested I prefer second option. Generally, I prefer double dispatch over switching on Types.

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288