Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:27:05+00:00 2026-06-12T08:27:05+00:00

List<Customer> customers = new List<Customer>(); int id = 0; int click = -1; public

  • 0
   List<Customer> customers = new List<Customer>();
    int id = 0;
    int click = -1;

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void AddButton_Click(object sender, EventArgs e)
    {
        Customer rec1 = new Customer("C0020", "Alfred", "Campbelltown", 1500, 2006);
        Customer rec2 = new Customer("C0021", "Ryder", "Liverpool", 2000, 2008);
        Customer rec3 = new Customer("C0022", "Alison", "Strathfield", 5500, 2012);
        Customer rec4 = new Customer("C0023", "Eliza", "Liverpool", 6000, 2012);
        Customer rec5 = new Customer("C0024", "Natsu", "Campbelltown", 2560, 2011);

        customers.Add(rec1);
        customers.Add(rec2);
        customers.Add(rec3);
        customers.Add(rec4);
        customers.Add(rec5);

        click = customers.Count - 1;

    }

How do i calculate the total balance by particular suburb? I can calculate the total balance of everything by using the code below:

        double total = 0;

        foreach (Customer Total in customers)
            total += Total.Balance; //Total Balance

Any Ideas? thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:27:07+00:00Added an answer on June 12, 2026 at 8:27 am

    In C# >= 3.5 simplest way will be using LINQ:

    customers.Where(c => c.Suburb == "whatever").Sum(c => c.Balance);
    

    Sorry, you didn’t describe your Customer props, so I’ve assumed them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Generic List as below public static readonly List<Customer> Customers = new
In the web servce I say public List<Customer> GetCustomers() { PR1Entities dc = new
List<Customer> _customers = getCustomers().ToList(); BindingSource bsCustomers = new BindingSource(); bsCustomers.DataSource = _customers; comboBox.DataSource =
I have a list of Customers. Each customer has an address and some customers
My entities are these: public class Customer { public Customer() { Invoices = new
This is the method in my Model : public IList<Customer> GetProfileCustomer(int id) { var
I have an entity Customer public class Customer { public virtual int ID {
I am using a datalist on customer page to list all customers. There is
This is my class structure public class Customer { List<Address> add = null; public
List<Customer> c= new List<Customer>() { new Customer{Id = 1, Name = Bruce}, new Customer{Id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.