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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:29:26+00:00 2026-06-17T15:29:26+00:00

I create this class for a test. I want to compare to List of

  • 0

I create this class for a test.
I want to compare to List of the class and get different class between ListA and ListB. In my example the result get only class of ListB.

I do the same thin with list of string and work it

Class Example

public class FileNode
{
    public string Source { get; set; }
    public int Id { get; set; }
}

List<FileNode> ListA = new List<FileNode>
{
    new FileNode{ Id = 1, Source="a" },
    new FileNode{ Id = 2, Source="b" },
};

List<FileNode> ListB = new List<FileNode>
{
    new FileNode{ Id = 1, Source="a" },
    new FileNode{ Id = 2, Source="b" },
    new FileNode{ Id = 3, Source="c" },
};
List<FileNode> ListAB = ListB.Where(m => !ListA.Contains(m)).ToList();

String example, it’s works

List<string> a = new List<string> {"a","b","c","d","e" };
List<string> b = new List<string> {"a","b","c","d" };
List<string> ab = a.Where(m => !b.Contains(m)).ToList();
  • 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-17T15:29:28+00:00Added an answer on June 17, 2026 at 3:29 pm

    Well Contains is going to call Equals on the elements – and may also use GetHashCode (I doubt it, but you should override it consistently anyway). So you need to override Equals(object) and GetHashCode() in FileNode. (By default, you’ll get reference equality.)

    Note that as soon as you start trying to use Contains in a query which will execute in the database, it could behave completely different – it wouldn’t be looking at your Equals/GetHashCode methods at that point.

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

Sidebar

Related Questions

I want to extend RuntimeException to create this specific exception: class CompileLinkException extends RuntimeException
Here's a very simple example of what I'm trying to get around: class Test(object):
I have code like this: public class test { public string aa { get;
I want to create a method in superclass of test-class that stubs some commonly
I want to create custom xml serialization by implementing IXmlSerializable. I've got this test
In C++, I create this class: public ref class UConfig { public: UConfig(short nr);
I have this class that have a function to load other classes and create
I have a class and this class has a delegate protocol. I create an
I need to create a class to handle audio AudioTrack. In this class must
How do i create aliases in c# Take this scenario class CommandMessages { string

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.