On 8/8/07, Igal Yoffe <[EMAIL PROTECTED]> wrote:
>
>
> How many times you've seen a variant of the following code:
> <YourPreferredLoggingStream>.WriteLine("Number of foo-bars is: {0}",
> constant_NumOfFooBars);


Frankly?  Never.  If it's a constant, why would I log it?


> Also, why bother with interning strings but not bother interning
> constants?


A string is always an object.  Interning a string has two benefits:
1) You get reduced memory usage as soon as the same string is ldstr'd the
second time.
2) Generation 0 isn't cluttered with string literals, which reduces the risk
of other objects being promoted to Generation 1.

Neither of these is true when it comes to boxing an int32 -- which is in any
event, a pretty rare operation.  With the advent of generics in .NET 2.0,
I'm not sure I ever have a good reason for boxing other than the varargs
string formatting functions.

--
Curt Hagenlocher
[EMAIL PROTECTED]

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to