473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Swtich statement

I am updating some code that has a switch statement. The code was VB.net and
I using C#.net. The problem is the switch statement is giving me a syntax
error on this line. It doesn't like the case 1,2,3,4. What is the syntax for
this?

case 1,2,3,4:

Nov 9 '06 #1
5 3462
case 1:
case 2:
case 3:
case 4:
// code
break;
Nov 9 '06 #2
"newguy" <ne****@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
>I am updating some code that has a switch statement. The code was VB.net
and
I using C#.net. The problem is the switch statement is giving me a syntax
error on this line. It doesn't like the case 1,2,3,4. What is the syntax
for
this?

case 1,2,3,4:
case 1:
case 2:
case 3:
case 4:
Nov 9 '06 #3
I should have said this in my first post. the people that wrote this code
said not to change it. they have case 1,2,3,4 to catch error codes returned
by there app. the same error message applies to all 1,2,3,4. I know I can
break it down like your example and copy the error message but i just wanted
to know how to do it the other way. Thanks for you help.

"Marc Gravell" wrote:
case 1:
case 2:
case 3:
case 4:
// code
break;
Nov 9 '06 #4
No - my example has only 1 code block, not 4; there is no need for
duplication. The same "// code" section will get run in all 4 cases.

In C#, you can "drop through" a block if and only if you haven't provided
any code. You can't do the C-style cumulative cases, however.

But just put your code where my "// code" is and it will work fine.

Marc
Nov 9 '06 #5
Okay I see what your saying. Thanks

"Marc Gravell" wrote:
No - my example has only 1 code block, not 4; there is no need for
duplication. The same "// code" section will get run in all 4 cases.

In C#, you can "drop through" a block if and only if you haven't provided
any code. You can't do the C-style cumulative cases, however.

But just put your code where my "// code" is and it will work fine.

Marc
Nov 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.