0
我已經有了對象集團與和列表(vb.net)
Class Bundledtellingen
Property tTimestamp As String
Property tValue As Double
End Class
現在,我想這組列表中tTimestamp列表,總結tValue。通過搜索類似的問題,很明顯最好的方法是使用Linq。我已經把這個一起:
Dim query = bundledlist.GroupBy(_
Function(telling) telling.tTimestamp, _
Function(telling) telling.tTimestamp, _
Function(ts, values) New With _
{.Key = ts, _
.Sum = values.Sum()} _
)
Using writer As StreamWriter = New StreamWriter("C:\test.txt")
For Each result In query
writer.WriteLine(result.Key & " " & result.Sum)
Next
End Using
至於我可以通過查看http://msdn.microsoft.com/en-us/library/bb534493.aspx#Y0這應該工作的例子來講,雖然我得到以下異常:「重載決策失敗,因爲沒有可訪問的‘點心’接受此參數數量「。
嗨,謝謝你指出我在正確的方向。我只需要用tell.tValue替換第二個tell.tTimestamp。 – vandaemb 2013-04-18 07:12:45