Throwing exceptions in switch statements when no specified case can be handled

后端 未结 9 1579
你的背包
你的背包 2021-01-30 15:52

Let\'s say we have a function that changes a password for a user in a system in an MVC app.:

public JsonResult ChangePassword
    (string username, string curren         


        
9条回答
  •  野的像风
    2021-01-30 16:34

    I always throw an exception in this case. Consider using InvalidEnumArgumentException, which gives richer information in this situation.

提交回复
热议问题