using a switch for a range of numbers
-
Sorry for the basic post, but I have looked everywhere and I can't figure out if this is possible or not. I am wondering if it is possible to check and variable to see if it is between certain ranges of numbers using a switch statement. Ex: switch (int){ case (between 1 and 10): case (between 11 and 20: and so on. Let me know if know. Jason
-
Sorry for the basic post, but I have looked everywhere and I can't figure out if this is possible or not. I am wondering if it is possible to check and variable to see if it is between certain ranges of numbers using a switch statement. Ex: switch (int){ case (between 1 and 10): case (between 11 and 20: and so on. Let me know if know. Jason
-
Sorry for the basic post, but I have looked everywhere and I can't figure out if this is possible or not. I am wondering if it is possible to check and variable to see if it is between certain ranges of numbers using a switch statement. Ex: switch (int){ case (between 1 and 10): case (between 11 and 20: and so on. Let me know if know. Jason
-
Sorry for the basic post, but I have looked everywhere and I can't figure out if this is possible or not. I am wondering if it is possible to check and variable to see if it is between certain ranges of numbers using a switch statement. Ex: switch (int){ case (between 1 and 10): case (between 11 and 20: and so on. Let me know if know. Jason
This is one of those features that VB has that I wish C# supported. You can just add case statements for each of the values adding the break statement to the last case in the range switch (value) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: DoSomething (); break; } not pretty but it works.