Solved

how to calc totals - LINQ

Posted on 2013-01-15
4
221 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:knowlton
  • 2
4 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 250 total points
Comment Utility
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
Does the article cover this:

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


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

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
Comment Utility
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:knowlton
Comment Utility
Thanks guys!  : )
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now