2010-03-31 4 views
3

Possible en double:
C# - Is there a better alternative than this to ‘switch on type’?C# - Quelle est la meilleure alternative pour 'allumer le 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.) Ou est-il une meilleure façon. ...?

Veuillez tenir compte à la fois de la rapidité et de la facilité de lecture du code.

+0

voir aussi 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

+0

et http://stackoverflow.com/questions/ 94305/what-is-quick-switch-on-string-ou-elseif-on-type http://stackoverflow.com/questions/6304815/why-is-this-switch-on-type-case-considered- déroutant http://stackoverflow.com/ques/5947343/comment-basculer entre-types-d'-objets-possibles http://stackoverflow.com/questions/10115028/best-way-to-switch-behavior-based-on-type – Mikhail

Répondre

1

De tous suggéré je préfère la deuxième option. Généralement, je préfère double dispatch sur l'activation de Type s.

Questions connexes