September 28, 2010

typeof and typeid

[c#] typeof($Type$) == [C++] $Type$::typeid

September 22, 2010

Timespan Formatting

timeSpan.ToString("hh:mm:ss") equivalent. (Only available in .Net 4!)
  TimeSpan timeSpan = new TimeSpan(DateTime.UtcNow.Ticks - scriptTime.Ticks);
   
  string timeStr = timeSpan.Hours.ToString().PadLeft(2, '0') + 
     ":" + timeSpan.Minutes.ToString().PadLeft(2, '0') + 
     ":" + timeSpan.Seconds.ToString().PadLeft(2, '0');