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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:25:39+00:00 2026-06-15T23:25:39+00:00

I have an class which contains the following properties: public class SomeClass() { public

  • 0

I have an class which contains the following properties:

public class SomeClass()
{
public Int32 ObjectId1 {get;set;}
public Int32 ObjectId2 {get;set;}
public Int32 ActiveThickeness {get;set;}
public Int32 ActiveFilterThickness {get;set;}
}

I also have 2 lists:

List<SomeClass> A
List<SomeClass> B

List A has data:

| ObjectId1 | ObjectId2 | ActiveThickness | ActiveFilterThickness |
-------------------------------------------------------------------
|     1     |     3     |       50        |           0           |
 ------------------------------------------------------------------
|     1     |     2     |       400       |           0           |
-------------------------------------------------------------------
|     4     |    603    |       27        |           0           |
-------------------------------------------------------------------

List B has data:

| ObjectId1 | ObjectId2 | ActiveThickness | ActiveFilterThickness |
-------------------------------------------------------------------
|     1     |     3     |       0         |         13671         |
 ------------------------------------------------------------------
|     1     |     2     |       0         |          572          |
-------------------------------------------------------------------
|    29     |    11     |       0         |         4283          |
-------------------------------------------------------------------

I want to merge A and B (using LINQ if possible) into List C of SomeCalss which contains data as followed:

| ObjectId1 | ObjectId2 | ActiveThickness | ActiveFilterThickness |
-------------------------------------------------------------------
|     1     |     3     |       50        |         13671         |
 ------------------------------------------------------------------
|     1     |     2     |       400       |          572          |
-------------------------------------------------------------------
|    29     |    11     |       0         |         4283          |
-------------------------------------------------------------------
|     4     |    603    |       27        |           0           |
-------------------------------------------------------------------

How can I achieve 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. Editorial Team
    Editorial Team
    2026-06-15T23:25:40+00:00Added an answer on June 15, 2026 at 11:25 pm

    Use GroupBy to group common objects and Sum to sum required properties

            var ab = A.Concat(B).GroupBy(x => new
                                                  {
                                                          x.ObjectId1,
                                                          x.ObjectId2
                                                  });
    
    
            var result = ab.Select(x => new SomeClass
                                            {
                                                    ObjectId1 = x.Key.ObjectId1,
                                                    ObjectId2 = x.Key.ObjectId2,
                                                    ActiveFilterThickness = x.Sum(i => i.ActiveFilterThickness),
                                                    ActiveThickeness = x.Sum(i => i.ActiveThickeness)
                                            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class which contains following properties: public virtual Vector3b SIZE {
I have a class that contains another poco class with simple get set properties:
I have the following ViewModel public class NewCustomerViewModel { public long CustomerId {get;set;} public
I have the following singleton class which contains the following property: public class Manager
I have a class which contains 5 properties. If any value is assingned to
I have a parent class which contains a child object. I am using set
i have a simple usercontrol with following properties: public partial class RichTextEditorControl : UserControl
Let's say you have a class called Customer, which contains the following fields: UserName
I have the following class which contains a hard coded URL that never changes:
I have a class included in a plugin which contains the following line user.rb

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.