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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:00:25+00:00 2026-06-11T19:00:25+00:00

Let’s say I have a class, Class A { ID; Name; LastModifiedDate; } and

  • 0

Let’s say I have a class,

Class A
{
    ID;
    Name;
    LastModifiedDate;
}

and I have Two List’s, ListA1 and ListA2,

ListA1 = new List<A>(); 
ListA2 = new List<A>();

ListA1.Add(new A{ ID=1, Name="A", LastModifiedDate='1/1/2000' })
ListA1.Add(new A{ ID=2, Name="B", LastModifiedDate='1/2/2000' })
ListA1.Add(new A{ ID=3,Name="C", LastModifiedDate='1/2/2000' })
...................................................


ListA2.Add(new A{ ID=4, Name="D", LastModifiedDate='1/4/2000' })
ListA2.Add(new A{ ID=1, Name="A", LastModifiedDate='1/5/2000' })
ListA3.Add(new A{ ID=2, Name="B", LastModifiedDate='1/2/2000' })

Now, I need to compare ListA1 and ListA2 by comparing LastModifiedDate. I need two new List’s, describing what are new/updated items in ListA1 and describing what are new/updated items in ListA2.

Update: The output I ma looking is that,

newUpadtedListA ={
    new A{ ID=4, Name="D", LastModifiedDate='1/4/2000' },
    new A{ ID=1, Name="A", LastModifiedDate='1/5/2000' }
}

newUpadtedListB ={
    new A{ ID=3, Name="C", LastModifiedDate='1/2/2000' }
}
  • 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-11T19:00:26+00:00Added an answer on June 11, 2026 at 7:00 pm

    You can use Linq and Enumerable.Except:

    var a1Modified = ListA1.Select(x => x.LastModifiedDate);
    var a2Modified = ListA2.Select(x => x.LastModifiedDate);
    var a1NotInA2LastModified = a1Modified.Except(a2Modified);
    List<A> newInA1 = (from a1 in ListA1
                  join notInA2 in a1NotInA2LastModified
                  on a1.LastModifiedDate equals notInA2
                  select a1).ToList();
    

    and the opposite, what’s new in List2:

    var a2NotInA1LastModified = a2Modified.Except(a1Modified);
    List<A> newInA2 = (from a2 in ListA2
                  join notInA1 in a2NotInA1LastModified
                  on a2.LastModifiedDate equals notInA1
                  select a2).ToList();
    

    Edit: according to your last edit that ID is the only key column. This should give you all you need in a fairly efficient way:

    var a1IDs = ListA1.Select(a => a.ID);
    var a2IDs = ListA2.Select(a => a.ID);
    var newInA1 = from l1 in ListA1
                  join newA1 in a1IDs.Except(a2IDs)
                  on l1.ID equals newA1
                  select l1;
    var newInA2 = from l2 in ListA2
                  join newA2 in a2IDs.Except(a1IDs)
                  on l2.ID equals newA2
                  select l2;
    var updatedInA1 = from l1 in ListA1
                      join l2 in ListA2
                      on l1.ID equals l2.ID
                      where l1.LastModifiedDate > l2.LastModifiedDate
                      select l1;
    var updatedInA2 = from l2 in ListA2
                      join l1 in ListA1
                      on l2.ID equals l1.ID
                      where l2.LastModifiedDate > l1.LastModifiedDate
                      select l2;
    

    You can enumerate these sequences and do whatever you need to do to add or update the new/changed items.

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

Sidebar

Related Questions

let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let me explain best with an example. Say you have node class that can
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have two tables orgs and states orgs is (o_ID, state_abbr) and
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have window.open (without name parameter), scattered in my project and I
Let's say I have the following classes : public class MyProductCode { private String
Let's say, we have and list of objects in variable called articles, each object
Let's say you have two different categories of users with different profiles: one for
Let's say you have a class called Customer, which contains the following fields: UserName

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.