This example *is* unrealistic, but it shows up again and again in tutorials. If you're calling Console.WriteLine all the time (say, in a console app), is the supposed expense of boxing really a problem?
-----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Curt Hagenlocher Sent: Wednesday, August 08, 2007 9:37 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] compiler considerations On 8/8/07, Igal Yoffe <[EMAIL PROTECTED]> wrote: > > > There is no doubt that when Writeline in called it expects an object, > the question is whether this boxing takes place when the argument is > passed to Writeline or prepared in advance. Furthermore, it seems > unwise that in the following code would perform boxing 10,000 (0x2710) times. > > for(int i=0; i<10000; i++) WriteLine("{0}",1); Sure it seems unwise, but this example is both unrealistic and pathological. And the performance issue (such as it is) can trivially be avoided with a small change in the user code. All in all, I'd prefer my optimization dollar to be spent somewhere else. =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com