Consider the following code: Console.Writeline("{0} {2}",1,(new MyStruct()).ToString());
The number of boxings in such code is between 0 to 2, depending on the implementation of the compiler. Straightforwardly, two boxings are obvious, viz., int boxing and struct's boxing before calling ToString. However, it could be the case that in compile time the compiler creates "object(1)" (really a trivial optimization) for the integer, and moreover have special vtable logic for structures (recall that structures could not be inherited) which calls ToString directly, thus no boxings at all. While I could examine the ilasm generated by _my_ compiler I would be really glad to know what do you think _typical_ (e.g. microsoft's csc) compiler would do? =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com