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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:12:35+00:00 2026-05-15T17:12:35+00:00

I have two List’s that contain a object of Tag like List i need

  • 0

I have two List’s that contain a object of Tag like List i need to find excluded and included to do an update operation how do find the difference in them both since they contain a Tag object. Can you use Contains function with a Tag object inside the list need some help.

Im using asp.net 2.0 so please if you can help me do it in that language please.

List<Tag> tag1 = new List<Tag>()  
tag1.Add(new Tag("Apples"));  
tag1.Add(new Tag("Oranges"));  
tag1.Add(new Tag("Pears"));  

List<Tag> tag2 = new List<Tag>()  
tag2.Add(new Tag("Apples"));  
tag2.Add(new Tag("Bananas"));  

txtExcluded.Text = list1;  
txtIncluded.Text = list2  
  • 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-15T17:12:36+00:00Added an answer on May 15, 2026 at 5:12 pm

    You could implement IEquatable<T>:

    public class Tag : IEquatable<Tag>
    {
        public Tag(string text)
        {
            Text = text;
        }
        public string Text { get; set; }
    
        public bool Equals(Tag other)
        {
            return other != null && string.Equals(Text, other.Text);
        }
    
        public override bool Equals(object obj)
        {
            return Equals(obj as Tag);
        }
    
        public override int GetHashCode()
        {
            return (Text ?? string.Empty).GetHashCode();
        }
    }
    

    Now the Contains method could work like this:

    var list = new List<Tag>(new[]
    {
        new Tag("Apples"),
        new Tag("Oranges"),
        new Tag("Pears"),
    });
    
    var tag = new Tag("Pears");
    bool isContains = list.Contains(tag); // returns true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two objects List<Report> List<Newsletter> I need certain properties like Id Date Status
I have two List<T> objects that I would like to intersect, but I get
I have two list that consist out of the same object. I want to
i have two list, i wanted to update the second list while adding a
I have two list boxes like show below, side by side. They both have
I have two generic list that have been unioned. Say listA and listB, both
I have two lists List<WorkOrder> and List<PlannedWork> I would like join the two lists
I have two list like this: list1 = [{'id':1, 'name':'foo', 'age':20}, {'id':2, 'name':'foo', 'age':20}]
I have two List, this complex object has 4 public properties of reference type.
I have two list boxes that I am trying to pass multiple values from

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.