Click here to Skip to main content
15,891,184 members
Home / Discussions / C#
   

C#

 
GeneralRe: Where do I release my object's expensive resources, if not in the destructor? Pin
Scott Dorman2-Aug-08 15:23
professionalScott Dorman2-Aug-08 15:23 
QuestionCannot debug c# dll Pin
manju#12330-Jul-08 20:36
manju#12330-Jul-08 20:36 
AnswerRe: Cannot debug c# dll Pin
Christian Graus30-Jul-08 20:59
protectorChristian Graus30-Jul-08 20:59 
Questionhow many rows and columns are hidden in an excel sheet Pin
Mogaambo30-Jul-08 20:20
Mogaambo30-Jul-08 20:20 
Question'switch' statement efficiency in C# Pin
scody30-Jul-08 19:50
scody30-Jul-08 19:50 
AnswerRe: 'switch' statement efficiency in C# Pin
Christian Graus30-Jul-08 20:07
protectorChristian Graus30-Jul-08 20:07 
GeneralRe: 'switch' statement efficiency in C# Pin
scody30-Jul-08 21:12
scody30-Jul-08 21:12 
AnswerRe: 'switch' statement efficiency in C# Pin
Guffa30-Jul-08 22:02
Guffa30-Jul-08 22:02 
scody wrote:
One of the books on C# stated

"One intriguing point about the switch statement in C# is that the order of the cases doesn’t matter—we can even put the default case first!"

This statement made me think..


That statement is talking about the syntax of the switch construct, not the performance.

The performance is a whole different matter:

The order of the case labels matters if you only have five of less of them. Then you should place the most commonly used ones first.

If you have more than five case labels the switch uses a hash table, so then the order of the case labels doesn't matter at all.

(I determined this by performance testing a switch in C# 3 (VS2008) targetting framework 3.5. The implementation may of course differ in older versions of the compiler or framework, but I doubt that this was ever any different.)

Despite everything, the person most likely to be fooling you next is yourself.

GeneralRe: 'switch' statement efficiency in C# Pin
leppie30-Jul-08 22:52
leppie30-Jul-08 22:52 
GeneralRe: 'switch' statement efficiency in C# Pin
Christian Graus30-Jul-08 23:57
protectorChristian Graus30-Jul-08 23:57 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie31-Jul-08 0:14
leppie31-Jul-08 0:14 
GeneralRe: 'switch' statement efficiency in C# Pin
Guffa31-Jul-08 1:57
Guffa31-Jul-08 1:57 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie31-Jul-08 2:17
leppie31-Jul-08 2:17 
GeneralRe: 'switch' statement efficiency in C# Pin
Guffa31-Jul-08 2:58
Guffa31-Jul-08 2:58 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie31-Jul-08 5:46
leppie31-Jul-08 5:46 
GeneralRe: 'switch' statement efficiency in C# Pin
leppie30-Jul-08 22:51
leppie30-Jul-08 22:51 
GeneralRe: 'switch' statement efficiency in C# Pin
Guffa31-Jul-08 1:18
Guffa31-Jul-08 1:18 
AnswerRe: 'switch' statement efficiency in C# Pin
PIEBALDconsult3-Aug-08 17:07
mvePIEBALDconsult3-Aug-08 17:07 
QuestionConvert a Java timestamp to C# DateTime object Pin
cyrus_virus30-Jul-08 19:26
cyrus_virus30-Jul-08 19:26 
AnswerRe: Convert a Java timestamp to C# DateTime object Pin
Christian Graus30-Jul-08 20:03
protectorChristian Graus30-Jul-08 20:03 
AnswerRe: Convert a Java timestamp to C# DateTime object Pin
Mike Dimmick31-Jul-08 1:16
Mike Dimmick31-Jul-08 1:16 
AnswerRe: Convert a Java timestamp to C# DateTime object Pin
curtisk31-Jul-08 3:49
curtisk31-Jul-08 3:49 
Questiongetting excel cell reference Pin
Mogaambo30-Jul-08 19:19
Mogaambo30-Jul-08 19:19 
Questionproblem to solve the warning!! Pin
ktamanna30-Jul-08 18:33
ktamanna30-Jul-08 18:33 
AnswerRe: problem to solve the warning!! Pin
Christian Graus30-Jul-08 19:39
protectorChristian Graus30-Jul-08 19:39 

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.