PC Review


Reply
Thread Tools Rate Thread

Boxing with SystemDateTime.ToString

 
 
Ian McCutcheon
Guest
Posts: n/a
 
      16th Sep 2009
I was wondering if anyone has run into this. The following uses C# with .net
compact framework 3.5 running on WinCE 6.0 R2.

I have a string builder and am using it to build a string that contains the
current date and time. I get the date and time using:

System.DateTime currTime = System.DateTime.Now;

I then format it into my string builder as follows:

dateTimeString.Length = 0;
dateTimeString.Append(currTime.ToString("MMM dd yy "));

Now the above will not show any boxing in the remote performance monitor
(see field Boxed Value Types). But if I change the format string to (year
from yy to yyyy)

dateTimeString.Length = 0;
dateTimeString.Append(currTime.ToString("MMM dd yyyy "));


Now I get a value of 1 reported for boxing. The IL does not show any box
operation so I'm assuming it is coming from the .ToString method (and this
assumes that the RPM tracks those that occur in the .NetCF too which I am not
sure about).

Has anyone else experienced this and found a work around. I realize one box
operation is pretty minor in the grand scheme of things but found it
interesting at least.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
boxing when calling ToString on a struct object Tony Johansson Microsoft C# .NET 4 3rd Feb 2010 07:51 PM
Now.date.tostring and now.seconds.tostring() giving different result. archana Microsoft C# .NET 2 8th Aug 2006 06:38 AM
ToString.....or not ToString (that is the question) Scott M. Microsoft Dot NET Framework 12 29th Aug 2005 01:49 AM
Difference between boxing a primitive type and boxing a custom str =?Utf-8?B?RGF2aWQgU2hlbg==?= Microsoft Dot NET Framework 5 13th Nov 2004 04:21 AM
Changing systemdatetime in Command prompt =?Utf-8?B?SGFuc2pl?= Windows XP General 2 19th Mar 2004 11:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:45 AM.