Solved

how to calc totals - LINQ

Posted on 2013-01-15
4
222 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
ID: 38779465
0
 
LVL 5

Author Comment

by: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:knowlton
ID: 38779654
Thanks guys!  : )
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 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

12 Experts available now in Live!

Get 1:1 Help Now