How to sum a field in a List

Total Post:135

Points:947
VB.Net 
 1462  View(s)
Ratings:
Rate this:

I have:

 Dim aList As List(Of myObj.Answers) = myObj.GetResults(someID)

How can I get the sum of aList.AnswerCount field in my List(Of myObj) ?

  1. Post:378

    Points:2694
    Re: How to sum a field in a List

    Hi Chintoo, 


    try this:

    aList.Sum(Function(i) i.AnswerCount)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!