Click here to Skip to main content
15,914,070 members
Home / Discussions / C#
   

C#

 
QuestionHow does this site work? Pin
soybeanny23-Mar-09 17:53
soybeanny23-Mar-09 17:53 
AnswerRe: How does this site work? Pin
Roger Wright23-Mar-09 20:12
professionalRoger Wright23-Mar-09 20:12 
QuestionHow do i include library from other softwares into my project? Pin
RogerLum23-Mar-09 17:16
RogerLum23-Mar-09 17:16 
AnswerRe: How do i include library from other softwares into my project? Pin
mcldev23-Mar-09 17:37
mcldev23-Mar-09 17:37 
QuestionDatagrid-Table relations Pin
Ramkithepower23-Mar-09 15:47
Ramkithepower23-Mar-09 15:47 
Questionswicth & case? Pin
dec8223-Mar-09 15:33
dec8223-Mar-09 15:33 
AnswerRe: swicth & case? Pin
Xmen Real 23-Mar-09 15:40
professional Xmen Real 23-Mar-09 15:40 
AnswerRe: swicth & case? Pin
Luc Pattyn23-Mar-09 15:52
sitebuilderLuc Pattyn23-Mar-09 15:52 
Hi,

you can't fall through from one case to the next (except for empty cases), there must be an explicit change of program flow (break, return, throw, goto, ...)

your C++ code looks like a sequence of operations with a selectable start.
the easiest way IMO to get that done in C# is by putting everything in a for( ; ; ) {} and using a continue after each number++, plus of course providing an exit somehow.

However doing so there will be a performance hit since now the switch dispatching code gets executed over and over.

The ugly but high-performance alternative uses goto and labels; something like:
case 76:
label76:
    ...
    goto label77;
case 77:
label77:
    ...
    goto label78;


This adds two lines per case instead of one, but executes the switch only once.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


GeneralRe: swicth & case? Pin
PIEBALDconsult23-Mar-09 16:14
mvePIEBALDconsult23-Mar-09 16:14 
GeneralRe: swicth & case? Pin
Luc Pattyn23-Mar-09 16:23
sitebuilderLuc Pattyn23-Mar-09 16:23 
GeneralRe: swicth & case? Pin
PIEBALDconsult23-Mar-09 16:25
mvePIEBALDconsult23-Mar-09 16:25 
GeneralRe: swicth & case? Pin
dec8223-Mar-09 16:16
dec8223-Mar-09 16:16 
GeneralRe: swicth & case? Pin
Mycroft Holmes23-Mar-09 16:44
professionalMycroft Holmes23-Mar-09 16:44 
GeneralRe: swicth & case? Pin
PIEBALDconsult23-Mar-09 17:14
mvePIEBALDconsult23-Mar-09 17:14 
GeneralRe: swicth & case? Pin
dec8224-Mar-09 2:22
dec8224-Mar-09 2:22 
GeneralRe: swicth & case? Pin
PIEBALDconsult24-Mar-09 3:54
mvePIEBALDconsult24-Mar-09 3:54 
QuestionODAC and DbProviderFactory Pin
devvvy23-Mar-09 14:43
devvvy23-Mar-09 14:43 
QuestionA Class to interface with many types Pin
iltallman23-Mar-09 14:27
iltallman23-Mar-09 14:27 
QuestionSaving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 14:24
Jacob Dixon23-Mar-09 14:24 
AnswerRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 15:19
professional Xmen Real 23-Mar-09 15:19 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 15:31
Jacob Dixon23-Mar-09 15:31 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 15:35
professional Xmen Real 23-Mar-09 15:35 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 15:40
Jacob Dixon23-Mar-09 15:40 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 15:44
professional Xmen Real 23-Mar-09 15:44 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 15:50
Jacob Dixon23-Mar-09 15:50 

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.