This project is read-only.
1
Vote

AV1536 Add a default block in switch/case

description

I'd reduce the level of this rule from (1) to (2) as in the next rule AV1537 since they're basically the same thing with different syntax, and I'd probably often choose to not do this if I only want to handle a few cases out of many. Adding a reasoned empty block every time only makes the code longer and mostly states what is already obvious. Here I'd go for less code.

Throwing an exception in the default or else block is a good idea though if the previous conditions are supposed to be comprehensive and other cases are unexpected.

comments

dennisdoomen wrote Jun 25, 2015 at 7:36 PM

We've moved. Please post any issues at https://github.com/dennisdoomen/csharpguidelines