c# - Generic method calling duplication -


i have following code:

switch (objecttype)             {                 case objecttype.userreview:                     return mymethod<userreview>();                 case objecttype.professionalreview:                     return mymethod<professionalreview>();                 case objecttype.question:                     return mymethod<question>();                 case objecttype.news:                     return mymethod<news>();                 default:                     throw new argumentoutofrangeexception("objecttype");             } 

now need same code calling method. there options implement without duplication , reflection?

sounds ideal opportunity replace conditional polymorphism. can promote objecttype.userreview class (it looks enum @ moment) , put switch block polymorphic method?


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -