Hi, I'll cut to the chase. I have two questions about switch that are simple, but I can't figure them out.
First:
in c# switch statements, do case statements have to be consecutive (with ints)?
For example:
switch(someInt)
{
case 1
// some code
case 2
// some code
case 3
// some code
}
or is it possible to do something like the following:
switch(someInt)
{
case 1
case 3
case 5
}
I know that normally if-else statements are used for something like that, but I'm just curious to know if its possible.
Also, is it considered magic numbers to use actual numbers in case statements? Or is is better practice to declare constants for use in the case statements?
Thanks!
Edit:
Thanks to all of you for your responses! I appreciate it.