I am looking for a help in solving an exercise using C#, LINQ.

I have a dictionary with `DateTime` as key and a `decimal` as value. I am trying to write a method that returns another dictionary with a value that is sum of all values of previous months and current month within that year. For the next year, the process repeats.

Input dictionary:

```
01/31/2015  100
02/28/2015  100
03/31/2015  100
;
; and so on
;
01/31/2017  200
02/28/2017  200
03/31/2017  200

```

Output should be as below:

```
01/31/2015  100
02/28/2015  200
03/31/2015  300
;
;
01/31/2017  200
02/28/2017  400
03/31/2017  600

```

Here is what I did so far. It computes the total but not resetting for the next year. In Jan 2016, it adds the value of Jan to the previous sum. I guess a GroupBy is needed before I write aggregate().

```
public static IDictionary<DateTime, decimal?> RunningTotal_NotResettingForNextYear(this IDictionary<DateTime, decimal?> inputDictionary)
{

    IDictionary<DateTime, decimal?> runningTotalDictinary =
        new Dictionary<DateTime, decimal?>(inputDictionary.Count);
    inputDictionary.Aggregate((decimal?)0, (sum, value) =>
    {
        sum = sum + value.Value;
        runningTotalDictinary.Add(value.Key, sum);
        return sum;
    });

    return runningTotalDictinary;
}

```