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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:49:40+00:00 2026-05-23T10:49:40+00:00

I have the following class called SearchItem, which extends another class called Claim. For

  • 0

I have the following class called SearchItem, which extends another class called Claim. For brevity, I’m simply including the class names and their properties.

public class SearchItem : Claim {

    public int FileStreamID { get; set; }
    public Int16 UploadedByLabID { get; set; }
    public string FileName { get; set; }
    public string TypeDesc { get; set; }
    public string UploadedByLab { get; set; }
    public string UploadedByUser { get; set; }
    public DateTime? UploadDate { get; set; }

}

public class Claim {

    public int ClaimID { get; set; }
    public string DOB_Format {
        get {
            string s = "";
            if (this.DOB.HasValue)
                s = this.DOB.Value.ToString("MM/dd/yyyy");
            return s;
        }
    }
    public string FirstName { get; set; }
    public string FullClaimDesc {
        get {
            return this.FullName + " (" + this.SSN_Mask + ")";
        }
    }
    public string FullName {
        get {
            string s = this.LastName + ", " + this.FirstName;
            if (!string.IsNullOrEmpty(this.MiddleName))
                s += " " + this.MiddleName;
            return s;
        }
    }
    public string LastName { get; set; }
    public string MiddleName { get; set; }
    public string SSN { get; set; }
    public string SSN_Mask {
        get {
            string s = "";
            if (this.SSN.Length > 0)
                s = Claim.FormatHyphens(this.SSN);
            return s;
        }
    }
    public string Suffix { get; set; }
    public DateTime? DOB { get; set; }
    public DateTime? RequestDate { get; set; }
    public Int16 OwnedByLabID { get; set; }
    public List<Int16> lstLabRecipientID { get; set; }
}

I have two lists that contains n SearchItems.

List<SearchItems> lstMain = new List<SearchItems>();
List<SearchItems> lstTemp = new List<SearchItems>();

Assume that lstMain contains 25 SearchItems and lstTemp contains 5 SearchItems. What I would like to do is use Intersect in order to retrieve the SearchItems that are the same between lstMain and lstTemp.

IEnumerable<SearchItem> results = lstMain.Intersect(lstTemp);

However, results always comes up empty. I am certain that the two lists contains 3 SearchItems that are identical, and by identical I mean that their properties yield the same values (ie – lstMain[2].ClaimID = 965 and lstTemp[0].ClaimID = 965, etc.).

So am I expecting too much out of the Intersect extension method? Can it not handle complext types that implement inheritance?

  • 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-23T10:49:40+00:00Added an answer on May 23, 2026 at 10:49 am

    Since I assume the class instances for the items that are considered “the same” are different in both lists you need a custom IEqualityComparer<SearchItem> to use Intersect(), you can pass it as a second parameter.

    In your implementation of IEqualityComparer<SearchItem> you would then have to compare the properties of two SearchItem instances to determine if they should be considered equal, an example can be found here.

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

Sidebar

Related Questions

Let's say you have a class called Customer, which contains the following fields: UserName
I have the following Class which basically creates a list of categories (called commands,
I have the following class: public class MainActivity extends Activity { /** Called when
I have the following use case: There's a class called Template and with that
I have created UITableCellView class called NoteCell . The header defines the following: #import
I have the following code in a static class called Methods that is archived
I have the following operator defined in a C++ class called StringProxy : operator
I have a class called EditMapUtilities. Here are some class properties that I want
I have the following class which is a decorator for an IDisposable object (I
I have an ORM class called Person, which wraps around a person table: After

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.