Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Which is more efficient, a switch statement or an if else chain?
Which is more efficient, a switch statement or an if else chain?
✍: Guest
The differences, if any, are likely to be slight. The switch statement was designed to be efficiently implementable, though the compiler may choose to use the equivalent of an if/else chain (as opposed to a compact jump table) if the case labels are sparsely distributed.
Do use switch when you can: it's certainly cleaner, and perhaps more efficient (and certainly should never be any less efficient).
2015-02-04, 1445👍, 0💬
Popular Posts:
In which event are the controls fully loaded ? Page_load event guarantees that all controls are full...
How To Increment Dates by 1? - MySQL FAQs - Introduction to SQL Date and Time Handling If you have a...
What is COCOMO I, COCOMOII and COCOMOIII? In CD we have a complete free PDF tutorial of how to prepa...
How does one iterate through items and records in a specified block? One can use NEXT_FIELD to itera...
Can you explain different software development life cycles -part II? Water Fall Model This is the ol...