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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:47:48+00:00 2026-06-06T05:47:48+00:00

In my code I am creating a List<> of the following class: public class

  • 0

In my code I am creating a List<> of the following class:

public class Calculations
{
        public int Year { get; set; }
        public double Payment { get; set; }
        public double AnnualInterest { get; set; }
        public double AnnualPrincipalSplit { get; set; }
        public double NLVBalance { get; set; }
        public double apportionedValue { get; set; }
        public double OpenMarketValue { get; set; }
        public double NotionalLoan { get; set; }
        public double ResidencyFee { get; set; }
        public double BalanceOfShare { get; set; }
        public double TotalShareOwnedOutright { get; set; }
        public double TotalEquity { get; set; }
}

The list holds data which represents the term of the investment (for example over 30 years, there would be 30 items in the list)

I have a variable called globalReviewPeriod, which is a integer, and this is used to define when the data in the list should be aggregated upon (For example, if the globalReviewPeriod was 5, and the term of the investment was 30 years, then data would need to be aggregated upon in years 5, 10, 15, 20, 25, and 30).

The aggregation itself is pretty straight forward, its just the cumulative values of the data contained in the class.

However I am struggling with the logic on how I could aggregate the data, given the logic I have defined above (i.e over the review periods).

Any pointers would be gratefully received.

  • 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-06T05:47:49+00:00Added an answer on June 6, 2026 at 5:47 am

    Use the overload of Where that allows you to filter based on index:

    var result = listCalculations
        .Where((x, index) => index % globalReviewPeriod == 0)
        .Sum(...); // Put some aggregation here.
    

    From the documentation, the lambda function is used as follows:

    predicate

    Type: System.Func

    A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

    Note that the above code will always include the first item, as this has index 0 which is divisible by every number. You may wish to use (index + 1) instead of index if you want to use 1-based indexing where the first element has index 1.

    var result = listCalculations
        .Where((x, index) => (index + 1) % globalReviewPeriod == 0)
        .Sum(...); // Put some aggregation here.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public class Hotel { public int ID { get;set
I have the following code: public static class ScraperMasterUriDetails { public static Dictionary<Guid, string>
I used an interface and class similar to following: public interface IIdentity { int
Please guide whats wrong with the following code that its not creating proper list
I have the following class: public class MySeat { public string Section { get;
Please advise.. In the following code(Tested. Will work fine) public class Exp_Test { public
I have the following code for creating tabs. It works at the end of
Eariler I happily used the following code for creating form elements (inside Zend_Form descendant):
I'm creating JPopUpMenu with following code: JPopupMenu popup1 = new JPopupMenu(); JPopupMenu popup2 =
I have the following collection contract defined: [CollectionDataContract(Name = Centres)] public class Centres :

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.