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

  • SEARCH
  • Home
  • 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 3723310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:13:27+00:00 2026-05-19T06:13:27+00:00

List has object which has properties as follows : public class PropertyDetails { public

  • 0

List has object which has properties as follows :

public class PropertyDetails
{

 public int Sequence { get; set; }

 public int Length { get; set; }

 public string Type { get; set; }

 public int Index { get; set; }

}

List will have sorted Sequence .

List has object values as follows:

Sequence= 1 Length=20 Type=”” Index=0

Sequence= 2 Length=8 Type=”” Index=0

Sequence= 3 Length=6 Type=”” Index=0

Sequence= 4 Length=20 Type=”” Index=0

Sequence= 5 Length=8 Type=”” Index=0

I want Linq query which will give me result List as

Sequence= 1 Length=20Type=”” Index=20

Sequence= 2 Length=8 Type=”” Index=28

Sequence= 3 Length=6 Type=”” Index=34

Sequence= 4 Length=20 Type=”” Index=54

Sequence= 5 Length=8 Type=”” Index=62

Where index is cumulative sum of Length considering sequence.

  • 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-05-19T06:13:28+00:00Added an answer on May 19, 2026 at 6:13 am

    I never though I’d say this, but I find Jon’s solution to be overengineering. Rather, I find LINQ to be the wrong solution for this problem. You want to manipulate state, not a good fit for traditional LINQ-operators.

    I’d just do this:

    var sum = 0;
    foreach (var p in list) {
      sum += p.Length;
      p.Index = sum;
    }
    

    LINQ is a hammer. Make sure you use the right tool for the problem, instead of just asking for hammering-advice.

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

Sidebar

Related Questions

I have an object which has a List in it's properties, I would like
I have a list of point object where point class has two properties X
I have a List<Vehicles> which contains 4 items: My Vehicles object has 2 properties:
If my object has a protected List<String> fileNote; What is the right way to
i have a list with objects. The object has a property 'Sales' which is
I have a class called Order which has properties such as OrderId , OrderDate
As input I have list of all objects where each object has properties: name
I've got a list which stores a number of objects. Each object has a
I have an ArrayList of an object which has properties Object.name and Object.url .
I have this class: public class CampaignMaps : List<CampaignMap> { }; The CampaignMap object

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.