Programming against an enum in a switch statement, is this your way to do?

前端 未结 12 2297
青春惊慌失措
青春惊慌失措 2020-12-24 09:15

Look at the code snippet:

This is what I normally do when coding against an enum. I have a default escape with an InvalidOperationException (I do not use ArgumentExc

12条回答
  •  抹茶落季
    2020-12-24 09:53

    That looks pretty reasonable to me. There are some other options, like a Dictionary, but what you have is simpler and should suffice for most simple cases. Always prefer simple and readable ;-p

提交回复
热议问题