Witam, tak jak w temacie mam tablice hash'y i chciałbym zliczyć a dokładniej zsumować wszystkie elementy value w tej tablicy (wiadomo że elementy key są unikatowe). Przykład (napisany w vb.net ale i w c# jest tak samo)
Dim Payments As System.Collections.HashTable
Dim Sum As Double
Public Function CalcPayments(ByVal key As Date, ByVal value As Double)
If (Payments Is Nothing) Then
Payments = New System.Collections.HashTable
End If
If (Not Payments.ContainsKey(key)) Then
Payments.Add(key, value)
Else
Payments(key) += value
End If
// W TYM MIEJSCU CHCIAŁBYM ZSUMOWAĆ WSZYSTKIE ELEMENTY
CalcPayments = Sum
End Function