TimeSpan.TotalMinutes vs. TimeSpan.Minutes
February 15th, 2006 by admin | Filed under .NET, Mobile.I was trying to find total minutes an event had been running.
TimeSpan ts = Compiles and runs… Not actually the behavior I was looking for. This returns the minute value of the time. Example: time span was 1:12 (1 hour, 12 minutes) This code evaluated true because 12 is less than 15. This is the correct code.
if This evaluated 72 > 15.
ts = DateTime.Now – myEvent.StartTime;
if (ts.Minutes > 15)>
Easy mistake to make.
Searching for “TimeSpan minutes” brings up your page and, since I didn’t notice “TotalMinutes” in intellisense, this was helpful to point it out. Thanks for posting!