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 70951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:48:41+00:00 2026-05-10T19:48:41+00:00

EDIT: I missed a crucial point: .NET 2.0 Consider the case where I have

  • 0

EDIT: I missed a crucial point: .NET 2.0

Consider the case where I have a list of unsorted items, for the sake of simplicity of a type like this:

class TestClass {     DateTime SomeTime;     decimal SomePrice;      // constructor } 

I need to create a report-like output, where the total prices for each day are accumulated. There should be one line for each item, folled by the appropriate summary lines.

Take this test data:

List<TestClass> testList = new List<TestClass> {  new TestClass(new DateTime(2008,01,01), 12), new TestClass(new DateTime(2007,01,01), 20), new TestClass(new DateTime(2008,01,01), 18) }; 

The desired output would be something like this:

2007-01-01:  20 Total: 20  2008-01-01:  12 18 Total: 30 

What’s the best way to approach such scenarios? In the case of such a list, I would implement the IComparable interface for TestClass, so that the list can be sorted.

To create the report itself, something like this could be used (let’s assume that we have methods for tasks like accumulating the prices, keeping track of the current date etc):

for (int i=0;i<testList.Count;i++) {     if (IsNewDate(testList[i]))     {         CreateSummaryLine();         ResetValuesForNewDate();     }      AddValues(testList[i]); }  // a final summary line is needed to include the data for the last couple of items. CreateSummaryLine(); 

This works alright, but I have a strange feeling as far as the second ‘CreateSummaryLines’ is concerned.

In what ways do you handle such situations (especially considering the fact, the we need to work with a List<> of items rather than a pre-categorized Dictionary or something like that)?

  • 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. 2026-05-10T19:48:42+00:00Added an answer on May 10, 2026 at 7:48 pm

    [edit] Since you are using .NET 2.0 with C# 3.0, you can use LINQBridge to enable this.

    LINQ; something like:

            var groups = from row in testList                   group row by row.SomeTime;         foreach (var group in groups.OrderBy(group => group.Key))         {             Console.WriteLine(group.Key);             foreach(var item in group.OrderBy(item => item.SomePrice))             {                 Console.WriteLine(item.SomePrice);             }             Console.WriteLine('Total' + group.Sum(x=>x.SomePrice));         } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer NOTE As of iOS7, you can no longer retrieve device… May 11, 2026 at 12:44 pm
  • added an answer myDataContext.Questions .OrderByDescending(q => q.Votes.Select(v => v.VoteValue).Sum()) In query comprehension (unchecked):… May 11, 2026 at 12:44 pm
  • added an answer What programming language/toolkit are you using? If you're using Cocoa… May 11, 2026 at 12:44 pm

Related Questions

Edit: I have solved this by myself. See my answer below I have set
EDIT: I'm still waiting for more answers. Thanks! In SQL 2000 days, I used
Edit: I am using SqlDataAdapters to fill the data sets. Sorry--I should have been
EDIT: I also have access to ESXLT functions. I have two node sets of
Once in a while my shared hosting environment gets compromised because, well, I failed
EDIT: I'm told that making you guys read means I get less attention. My
If I have a list of data in a text file seperated by a
In a static view, how can I view an old version of a file?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.