I would also add that syntax with 0 instead of the exact enum in the switch can become error prone. Consider the following code:
enum TestEnum { NA = 0, A }
and then
var e = TestEnum.NA; switch(e) { case 0: { break; } case TestEnum.A: { break; } }
It compiles and works well. However, if for some reason the enum declaration changes to
enum TestEnum { NA = 1, A }
everything will break.
Although in most situations, the default value for enum is 0 , and for this reason this syntax may occur, I would use the exact enum .
horgh Feb 19 '13 at 6:09 on 2013-02-19 06:09
source share