sum of timespans
- by frenchie
I have a collection of objects that include a timespan variable:
MyObject
{ TimeSpan TheDuration {get;set;}
}
I want to use linq to sum those times.
Of course, (from r in MyCollection select r.TheDuration).Sum(); doesn't work!
I'm thinking of changing the datatype of TheDuration to an int and then summing it and converting the sum to a TimeSpan. That'll be messy because each TheDuration in my collection is used in as a timespan somewhere else.
Any suggestion on this summation?