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

前端 未结 12 2296
青春惊慌失措
青春惊慌失措 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 10:02

    I would use the NotSupportedException.

    The NotImplementedException is for features not implemented, but the default case is implemented. You just chose not to support it. I would only recommend throwing the NotImplementedException during development for stub methods.

提交回复
热议问题