I'm working in c#. I have a sorted List of structures. The structure has a DateTime object which stores month and year and an integer which stores a value. The list is sorted by date. I need to traverse the list and combine it so that I only have one instance of the structure per date.
For example: My initial list would look like this:
{ (Apr10, 3), (Apr10, 2), (Apr10, -3), (May10, 1), (May10, 1), (May10, -3), (Jun10, 3) }
The resulting list should look like this:
{ (Apr10, 2), (May10, -1), (Jun10, 3) }
I'm looking for a simple / efficient solution.
The struct is:
struct CurrentTrade
{
public DateTime date;
public int dwBuy;
}
The list is:
private List<CurrentTrade> FillList