Click here to Skip to main content
15,917,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: Multithreaded Apps Pin
Ricardo Moncada22-Sep-03 10:27
Ricardo Moncada22-Sep-03 10:27 
GeneralFreeze form when it removing and reloading ctls Pin
Chris#22-Sep-03 5:57
Chris#22-Sep-03 5:57 
GeneralRe: Freeze form when it removing and reloading ctls Pin
Julian Bucknall [MSFT]22-Sep-03 7:03
Julian Bucknall [MSFT]22-Sep-03 7:03 
GeneralMS Word programming in C#. Pin
bimpy22-Sep-03 5:25
bimpy22-Sep-03 5:25 
GeneralC# switch case style Pin
Don Kackman22-Sep-03 5:24
Don Kackman22-Sep-03 5:24 
GeneralRe: C# switch case style Pin
Julian Bucknall [MSFT]22-Sep-03 7:14
Julian Bucknall [MSFT]22-Sep-03 7:14 
GeneralRe: C# switch case style Pin
Don Kackman22-Sep-03 8:39
Don Kackman22-Sep-03 8:39 
GeneralRe: C# switch case style Pin
Julian Bucknall [MSFT]22-Sep-03 10:05
Julian Bucknall [MSFT]22-Sep-03 10:05 
Ah ha! You're reading the "simplified" pages and I'm not surprised that you found ambiguity. Personally I tend to go to the authoritative source, the C# Language Reference. Here you see that

a switch statement consists of "switch" followed by an expression in parentheses followed by a switch block

a switch block consists of 0 or more switch sections, the whole wrapped in braces

a switch section consists of one or more switch labels followed by a list of statements

a switch label is either "case" followed by a constant expression followed by colon, or "default" followed by colon.

It is the statement list that cannot "fall through." (In fact, it's stated as "the end point of a statement list cannot be reachable," by which it means that you cannot get to the point just after the last statement in the statement list. In other words, the last statement in the list must be a "jump" type statement: break, goto, throw, etc.)

Hence, <phew>, you can have code that lokos like this:

switch (foo) {
case 1:
case 2:
DoSomething();
break;
...
}

As to the error message, I agree that it could be a little misleading, although it does correctly talk about the last switch label in the (possible) list of labels.

Cheers, Julian
Program Manager, C#

This posting is provided "AS IS" with no warranties, and confers no rights.
GeneralRe: C# switch case style Pin
Don Kackman22-Sep-03 10:18
Don Kackman22-Sep-03 10:18 
GeneralSmoothing as in MSVisio2002 Pin
Wizard_0122-Sep-03 3:54
Wizard_0122-Sep-03 3:54 
GeneralIE and .NET question Pin
yoaz22-Sep-03 2:34
yoaz22-Sep-03 2:34 
GeneralVisual Studion.Net 2002 closes by itself any time I try loading a C# project Pin
okoji Cyril22-Sep-03 1:20
okoji Cyril22-Sep-03 1:20 
GeneralRe: Visual Studion.Net 2002 closes by itself any time I try loading a C# project Pin
Braulio Dez22-Sep-03 5:06
Braulio Dez22-Sep-03 5:06 
GeneralRe: Visual Studion.Net 2002 closes by itself any time I try loading a C# project Pin
okoji Cyril23-Sep-03 2:02
okoji Cyril23-Sep-03 2:02 
GeneralBooks in C# Pin
nevhile.net22-Sep-03 1:02
nevhile.net22-Sep-03 1:02 
GeneralRe: Books in C# Pin
Azel Low22-Sep-03 3:12
Azel Low22-Sep-03 3:12 
GeneralRe: Books in C# Pin
Braulio Dez22-Sep-03 5:07
Braulio Dez22-Sep-03 5:07 
GeneralRe: Books in C# Pin
phimix22-Sep-03 6:10
phimix22-Sep-03 6:10 
GeneralDowloading a file from a web-site to client using c# Pin
simonzeng22-Sep-03 0:21
simonzeng22-Sep-03 0:21 
Questionhow to parse a dataset Pin
Birdy21-Sep-03 20:51
Birdy21-Sep-03 20:51 
AnswerRe: how to parse a dataset Pin
phimix22-Sep-03 6:13
phimix22-Sep-03 6:13 
GeneralMulti-line ListView control Pin
Member 46249021-Sep-03 20:10
Member 46249021-Sep-03 20:10 
GeneralKeyboard in C# Pin
deanoA21-Sep-03 17:37
deanoA21-Sep-03 17:37 
GeneralRe: Keyboard in C# Pin
Blake Coverett21-Sep-03 19:04
Blake Coverett21-Sep-03 19:04 
GeneralRe: Keyboard in C# Pin
Jim MacDonald22-Sep-03 6:10
Jim MacDonald22-Sep-03 6:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.