Reputation: 13
Is there a way to count all the timespans from a list into one timespan.
Like:
List(00:15:00 + 00:15:00) = TimeSpan(00:30:00)
Upvotes: 1
Views: 72
Reputation: 119017
You can use Linq Aggregate:
Aggregate
var timespans = new List<TimeSpan> { new TimeSpan(0, 15, 0), new TimeSpan(0, 15, 0) }; var totalTimespan = timespans.Aggregate((x, y) => x.Add(y));
Upvotes: 4