John Wood said:
http://msdn.microsoft.com/library/en-us/dndotnet/html/fastmanagedcode
.asp?frame=true
This definitely lists constant folding as a feature of the JIT... and I
would consider the automatic concatenation of that string expression as
constant folding wouldn't you?
To be honest, I'm not a big fan of that article. The idea of writing
the fastest possible code all the time is not one which appeals to me -
I far prefer to write *elegant* code which is easy to read, write and
maintain, and optimise any code which actually *needs* to be as fast as
possible.
Now, having said that, I'd have to look at exactly what is meant by
"constant folding" as far as the JIT is concerned. There may well be
things that the JIT can do which the compiler can't - they probably
have very different ideas of what a constant is. For example, suppose I
have two static readonly fields, which are initialised to some value at
runtime. The product of those fields *isn't* something the C# compiler
can compute and use once as a constant, but it *is* something the JIT
compiler might be able to do something with, depending on when it's
doing the JIT-compilation.