Saturday, December 22, 2007

TimeSpan.Seconds vs .TotalSeconds

The difference between the Seconds property and the TotalSeconds property is (or at least should be) pretty obvious, but based on experience it is a common bug to use .Seconds when you actually mean .TotalSeconds. For the readers out there that hasn't gotten the difference, think of a timespan of value 1 minute 23 seconds - here .Seconds is 23 and total seconds is 83.

As a rule of thumb, most often it's the Total variant you want, and yes, the same applies to all the other members too, (e.g. .Minutes, .Milliseconds vs. the corresponding .Total-prefixed ones)

Friday, December 21, 2007

"Practical Functional C#"

I just found an interesting blog post series about practical functional C#. It starts right here. Maybe I've missed something, but this feels like a fresh breath, being really down to earth and real world. I'm looking forward to future posts.

Friday, December 14, 2007

"Is there a constant for tab like Environment.Newline?"

..was a question a co-worker asked the other day. My first answer was no, as it is not really needed as a tab does not change between platforms as newline might (think Mono).

Then I realized, there actually *is* one, so I gave the following instructions:

  • Add a reference to Microsoft.VisualBasic.dll
  • add a using Microsoft.VisualBasic; statement
  • use Constants.vbTab

(And to avoid any misunderstandings, no, this was not a serious suggestion.)

Tuesday, December 11, 2007

"Thank you for the lasting contribution you made to Microsoft Visual Studio"

..that's what is engraved into the glass cube I got in the mailbox today.

vs2008-glasscube