Solved

how to calc totals - LINQ

Posted on 2013-01-15
4
227 Views
Last Modified: 2013-01-15
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
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 250 total points
ID: 38779465
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38779555
Does the article cover this:

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


where BidAmt is a string and comes in as "$115.23" ??
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 38779632
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
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 38779654
Thanks guys!  : )
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question