Click here to Skip to main content
15,886,038 members
Home / Discussions / C#
   

C#

 
Questiona problem of multiple forms Pin
Seraph_summer17-Nov-08 5:18
Seraph_summer17-Nov-08 5:18 
AnswerRe: a problem of multiple forms Pin
Ennis Ray Lynch, Jr.17-Nov-08 5:35
Ennis Ray Lynch, Jr.17-Nov-08 5:35 
QuestionCase select versus IF Statement Pin
EliottA17-Nov-08 4:59
EliottA17-Nov-08 4:59 
AnswerRe: Case select versus IF Statement Pin
Ennis Ray Lynch, Jr.17-Nov-08 5:03
Ennis Ray Lynch, Jr.17-Nov-08 5:03 
AnswerRe: Case select versus IF Statement Pin
#realJSOP17-Nov-08 6:04
mve#realJSOP17-Nov-08 6:04 
GeneralRe: Case select versus IF Statement Pin
EliottA17-Nov-08 6:12
EliottA17-Nov-08 6:12 
GeneralRe: Case select versus IF Statement Pin
#realJSOP17-Nov-08 6:31
mve#realJSOP17-Nov-08 6:31 
GeneralRe: Case select versus IF Statement Pin
Robert.C.Cartaino17-Nov-08 6:54
Robert.C.Cartaino17-Nov-08 6:54 
EliottA wrote:
So there is no actual efficiency when using a select case over a bunch of if statements?


In your situation, there is no "actual efficiency" in terms of performance using if statements vs using switch statements. If your deepest loops are taking 2 seconds to execute, switching from if to switch may improve your execution time by the tiniest fraction of a millisecond.

But that's besides the point. Unless you absolutely need to shave milliseconds off your code, decisions about how your code is organized should be about readability and communicating your intent to future readers of the code. Don't prematurely optimize.

That aside, there is more opportunity for a compiler to optimize long switch statements than with a series of if statements. The compiler will typically convert if statements into a series of compare-and-jump operations. Switch statements (in C#) can be implemented using techniques like jump tables (when comparing ints) or hash tables (when comparing strings) to increase code efficiency. But we're talking about real low-level, behind-the-scenes stuff that the average developer will likely never have to consider in real-world applications.

Enjoy,
Robert C. Cartaino
AnswerRe: Case select versus IF Statement Pin
Guffa17-Nov-08 6:29
Guffa17-Nov-08 6:29 
GeneralRe: Case select versus IF Statement Pin
#realJSOP17-Nov-08 11:03
mve#realJSOP17-Nov-08 11:03 
GeneralRe: Case select versus IF Statement Pin
Guffa17-Nov-08 13:09
Guffa17-Nov-08 13:09 
GeneralRe: Case select versus IF Statement Pin
Luc Pattyn17-Nov-08 15:29
sitebuilderLuc Pattyn17-Nov-08 15:29 
QuestionWhat is this friggin .config file? Pin
Dewald17-Nov-08 4:34
Dewald17-Nov-08 4:34 
AnswerRe: What is this friggin .config file? Pin
led mike17-Nov-08 4:46
led mike17-Nov-08 4:46 
GeneralRe: What is this friggin .config file? Pin
Dewald17-Nov-08 21:05
Dewald17-Nov-08 21:05 
GeneralRe: What is this friggin .config file? Pin
led mike18-Nov-08 6:05
led mike18-Nov-08 6:05 
GeneralRe: What is this friggin .config file? Pin
Dewald18-Nov-08 22:03
Dewald18-Nov-08 22:03 
GeneralRe: What is this friggin .config file? Pin
led mike19-Nov-08 5:31
led mike19-Nov-08 5:31 
GeneralRe: What is this friggin .config file? Pin
Dewald19-Nov-08 6:00
Dewald19-Nov-08 6:00 
Questionefficient Pin
dole.doug17-Nov-08 4:05
dole.doug17-Nov-08 4:05 
AnswerRe: efficient Pin
Pr@teek B@h!17-Nov-08 4:11
Pr@teek B@h!17-Nov-08 4:11 
GeneralRe: efficient Pin
dole.doug17-Nov-08 5:07
dole.doug17-Nov-08 5:07 
AnswerRe: efficient Pin
Ennis Ray Lynch, Jr.17-Nov-08 5:04
Ennis Ray Lynch, Jr.17-Nov-08 5:04 
AnswerRe: efficient Pin
Alan Balkany18-Nov-08 3:39
Alan Balkany18-Nov-08 3:39 
QuestionHTTP POST problem Pin
gr9fci17-Nov-08 3:40
gr9fci17-Nov-08 3:40 

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.