Boxing : Converting a value type to reference type is called Boxing.

Does calling ToString() on a String qualify as Boxing ??? No, I don't
think so at all. Try disassembling your assembly and checking the IL
generated. I'm almost positive that the IL generated for your
particular code snippet will not include a box-unbox pair of
instructions.


AFAIK, calling ToString() on a string object (admittedly a silly
thing
to do...all too common with amateurs) will only return the reference
of the string instance.


On Oct 3, 1:15 am, altja <[EMAIL PROTECTED]> wrote:
> So when you call a virtual method like ToString which inherits from
> System.Object you are taking the boxing hit.  So if I have some code
> that I know evaluates to a String and I don't use the ToString do I
> avoid the overhead or am I occuring the time anyway?
>
> I assume I avoid the time hit.  Therefore, by inuring some risk into
> my application am I increasing my speed.
>
> See my example.
> String errors = mMainDataSource.SelectSingleNode("my:myFields/
> my:validationErrors", NamespaceManager).Value;  no boxing
>
> String errors = mMainDataSource.SelectSingleNode("my:myFields/
> my:validationErrors", NamespaceManager).Value.ToString(); boxing
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
 <p><a href="http://feeds.feedburner.com/DotNetDevelopment";><img 
src="http://feeds.feedburner.com/~fc/DotNetDevelopment?bg=99CCFF&amp;fg=444444&amp;anim=1";
 height="26" width="88" style="border:0" alt="" /></a></p>
-~----------~----~----~----~------~----~------~--~---

Reply via email to