Is it possible to group up all equal keys in a Dictionary and add their corresponding TimeSpans together using LINQ?
Something like this (but this doesnt work)
var p = myDictionaryStringTimeStamp.Sum(x => x.Value.Add(myTimeStamp);
You can do it with the Aggregate
LINQ method like this:
var totalTime = myDictionaryStringTimeStamp
.Values
.Aggregate(new TimeSpan(0), (p, v) => p.Add(v));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With