How can I get running totals of integer values from a SortedDictionary?

Posted by user578083 on Stack Overflow See other posts from Stack Overflow or by user578083
Published on 2011-01-17T14:34:37Z Indexed on 2011/01/17 14:53 UTC
Read the original article Hit count: 125

Filed under:
|
|
|
SortedDictionary<int, string> typeDictionary = new SortedDictionary<int, string>(); 
SortedDictionary<int, int> lengthDictionary = new SortedDictionary<int, int>();

lengthDictionary has values in key value pair as follows:

<1,20>
<2,8>
<3,10>
<4,5>

i want LINQ query which will return me new list like as follows

<1,20>
<2,20+8=28>  // 20 from key 1
<3,28+10=38> // 28 from key 2
<4,38+5=43>  // 38 from key 3

Result should like this:

<1,20>
<2,28>
<3,38>
<4,43>

© Stack Overflow or respective owner

Related posts about c#

Related posts about sorting