Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
GeneralRe: Inputbox Pin
Nick Seng11-Jun-03 19:57
Nick Seng11-Jun-03 19:57 
QuestionAdd copyright symbol to Label or TextBox, anyone? Pin
Khang Nguyen11-Jun-03 12:54
Khang Nguyen11-Jun-03 12:54 
AnswerRe: Add copyright symbol to Label or TextBox, anyone? Pin
dynamic11-Jun-03 13:39
dynamic11-Jun-03 13:39 
GeneralRe: Add copyright symbol to Label or TextBox, anyone? Pin
Khang Nguyen12-Jun-03 5:02
Khang Nguyen12-Jun-03 5:02 
GeneralC# Excel COM Add-in Pin
Francis B.11-Jun-03 9:32
Francis B.11-Jun-03 9:32 
GeneralRe: C# Excel COM Add-in Pin
Kannan Kalyanaraman11-Jun-03 19:01
Kannan Kalyanaraman11-Jun-03 19:01 
GeneralWriting Faster Managed Code Pin
MtnBiknGuy11-Jun-03 8:36
MtnBiknGuy11-Jun-03 8:36 
GeneralRe: Writing Faster Managed Code Pin
Daniel Turini11-Jun-03 9:50
Daniel Turini11-Jun-03 9:50 
Optimization is fun, but not easy... Not a single concept is always true. Combine this with multi-threading (think about the SMP machines and the newer hyperthreading processors) and optimization is almost a try and guess game, although some basic techniques do help a bit.

MtnBiknGuy wrote:
I would think #2 is preferrable, but I see that most C# examples use the
style of #1. In fact, I often see the following in C# examples:

#2 does one inutile assignment, #1 don't. But to solve this doubt, remove the "= null" (BTW, this isn't a good practice, as it defeats some useful compiler warnings) and just look and the generated code with ILDASM. I bet they generate exactly the same IL, as the maximum stack space is allocated on the method's entry.

MtnBiknGuy wrote:
Finally, I'm curious if there are any performance differences between the
following two loops.

If the JIT is as good as MS sells it, #1 could even be slightly faster than #2. MS says JIT does common subexpression elimination and code motion of loop invariants, which is exactly what you did, but sometimes the JIT could even do it without the need for another local variable (imagine that you have several loops).

Notice that the JIT sometimes will do a better job than you. If T.x is a virtual property, and not a field, you can't safely do what you showed (T.x could have a side effect, e.g. incrementing a counter to keep usage count). Although sometimes the JIT hasn't all the info or time it needs to make all the possible optimizations, it has all the info it needs to always act safely.

On a side note, you should make all of your timings on Release builds, because the optimizer is disabled on the Debug builds.


Kant wrote:
Actually she replied back to me "You shouldn't fix the bug. You should kill it"
GeneralXML parsing solution for C# Pin
Anonymous11-Jun-03 6:49
Anonymous11-Jun-03 6:49 
GeneralRe: XML parsing solution for C# Pin
leppie11-Jun-03 7:00
leppie11-Jun-03 7:00 
GeneralRe: XML parsing solution for C# Pin
Daniel Turini11-Jun-03 7:43
Daniel Turini11-Jun-03 7:43 
GeneralRe: XML parsing solution for C# Pin
Nick Parker11-Jun-03 8:03
protectorNick Parker11-Jun-03 8:03 
GeneralRemoting !! Need Help !!!! Pin
Gaurika Wijeratne11-Jun-03 6:47
Gaurika Wijeratne11-Jun-03 6:47 
GeneralRe: Remoting !! Need Help !!!! Pin
leppie11-Jun-03 7:11
leppie11-Jun-03 7:11 
Generalmp3 Pin
kgoodrich11-Jun-03 5:45
kgoodrich11-Jun-03 5:45 
GeneralRe: mp3 Pin
shaunAustin11-Jun-03 5:57
shaunAustin11-Jun-03 5:57 
GeneralRe: mp3 Pin
kgoodrich11-Jun-03 6:17
kgoodrich11-Jun-03 6:17 
GeneralRe: mp3 Pin
shaunAustin11-Jun-03 7:56
shaunAustin11-Jun-03 7:56 
GeneralRe: mp3 Pin
J. Dunlap11-Jun-03 8:04
J. Dunlap11-Jun-03 8:04 
QuestionWhere's that article about Shell Toolbars? Pin
ThaRudeDude11-Jun-03 5:29
ThaRudeDude11-Jun-03 5:29 
AnswerRe: Where's that article about Shell Toolbars? Pin
Kannan Kalyanaraman11-Jun-03 5:45
Kannan Kalyanaraman11-Jun-03 5:45 
GeneralRe: Where's that article about Shell Toolbars? Pin
ThaRudeDude18-Jun-03 3:12
ThaRudeDude18-Jun-03 3:12 
GeneralXml Serialization Help Needed!! Pin
Ricardo Kirkner11-Jun-03 5:11
Ricardo Kirkner11-Jun-03 5:11 
GeneralRe: Xml Serialization Help Needed!! Pin
shaunAustin11-Jun-03 7:59
shaunAustin11-Jun-03 7:59 
GeneralRe: Xml Serialization Help Needed!! Pin
Ricardo Kirkner11-Jun-03 8:39
Ricardo Kirkner11-Jun-03 8: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.