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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:14:37+00:00 2026-05-15T04:14:37+00:00

Is there an easy way to get the relative complement of two sets? Perhaps

  • 0

Is there an easy way to get the relative complement of two sets? Perhaps using LINQ?

I have to find the relative compliment of a set A relative to B. Both A and B are of type HashSet<T> but I think the algorithm could be made more general (IEnumerable<T> or even ISet<T>)?

I could use a solution in either VB.NET or C#.

  • 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-15T04:14:38+00:00Added an answer on May 15, 2026 at 4:14 am

    Have you tried Enumerable.Except?

    setB.Except(setA)
    

    Example:

    HashSet<int> setB = new HashSet<int> { 1, 2, 3, 4, 5 };
    HashSet<int> setA = new HashSet<int> { 1, 3, 5, 7 };
    HashSet<int> result = new HashSet<int>(setB.Except(setA));
    
    foreach (int x in result)
        Console.WriteLine(x);
    

    Result:

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

Sidebar

Related Questions

Is there an easy way to get an two-dimensional array or something similar that
Is there an easy way to get a conflict summary after running a cvs
Is there an easy way to get the type of line ending that the
Given a Python object of any kind, is there an easy way to get
Is there an easy way to set the zoom level for a windows form
Is there an easy way to get the byte length of a string in
Is there an easy way to get the HTTP status code from a System.Net.WebException
Is there an easy way to get the name of the country on whose
Is there an easy way to get ride of the traditional quartiles returned by
is there an easy way to get a list of all columns of a

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.