In C# I mostly use switches together with enums. Why?
First because if you use the switch code snippet it will generate you a switch-case with all enum parameters, e.g.:
switch
public enum Values { A, B, C } static void Switch(Values value) { switch (value) { case Values.A: break; case Values.B: break; case Values.C: break; default: break; } }
Second if you add a new case it will automatically suggest to use a value of the enum and typecheck the cases, e.g. you couldn't use a string.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In C# I mostly use switches together with enums. Why?
First because if you use the
switch
code snippet it will generate you a switch-case with all enum parameters, e.g.:Second if you add a new case it will automatically suggest to use a value of the enum and typecheck the cases, e.g. you couldn't use a string.