• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

how to calc totals - LINQ

private List<Pres_Services_GetResult> _serviceItems

later on _serviceItems gets filled

once it is filled, how can I say "give me the TOTAL of <<some column>>"?

Using LINQ but am a noob to LINQ.
0
Tom Knowlton
Asked:
Tom Knowlton
  • 2
2 Solutions
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
Tom KnowltonWeb developerAuthor Commented:
Does the article cover this:

 _serviceItems.Sum(o => o.BidAmt);


where BidAmt is a string and comes in as "$115.23" ??
0
 
käµfm³d 👽Commented:
You'll need to convert that value to a numerical type before summing.

e.g.

_serviceItems.Select(o => decimal.Parse(o.BidAmt, NumberStyles.Currency))
             .Sum(o => o);

Open in new window

0
 
Tom KnowltonWeb developerAuthor Commented:
Thanks guys!  : )
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now