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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:09:37+00:00 2026-05-25T03:09:37+00:00

why linq’s except extension method does not have Except<TSource> Method (IEnumerable<TSource>,HashSet<TSource>) overload? for example

  • 0

why linq’s except extension method does not have Except<TSource> Method (IEnumerable<TSource>,HashSet<TSource>) overload?

for example

  var query = A.Except(B).where(x=>Criteria(x))

  foreach(item in query)
   {
     B.add(item);
     DoSomething(item);
   }

Given B is HashSet<T>, A is IEnumerable<T> or ICollection<T>
Here in each iteration Except take O(|B|) time.
why there is not a method that just take O(1) time, as B is Hashset anyway.

Update

my crude way is

var query = A.where(x=>!B.contains(x)).where(x=>Criteria(x))
  • 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-25T03:09:38+00:00Added an answer on May 25, 2026 at 3:09 am

    Here in each iteration Except take O(|B|) time

    No it doesn’t. Except is implemented internally with a collection similar to HashSet<T>. You can have a look at Jon Skeet’s proposed implementation in Edulinq. All elements in B are placed in a HashSet<T>, then elements of A are enumerated; if they’re not in the HashSet (checking this is a O(1) operation), they are returned in the output sequence.

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

Sidebar

Related Questions

Using Linq, trying to select all records not in my local set fails: var
linq only supports inner join, how to do left join using linq query. also
LINQ operators operate on the assumption that input sequences are not sorted, which is
This LINQ to SQL query From g In Db.Context.Current.Groups Select g.GroupID generates this SQL:
In LINQ, you can write a manual SQL query, take the results from it
Using linq and silverlight got this error....I am using POCO....DTO = POCO public IEnumerable.....
my LINQ query returns an ordered sequence of calendar dates, and i need to
LINQ-to-SQL had several ways, including a visualizer add-in, to view the generated SQL from
LINQ include missing. after reading this post: http://romiller.com/2010/07/14/ef-ctp4-tips-tricks-include-with-lambda/ i would like to use include.
Using Linq to SQL and the autogeneration capabilities of DBML, foreign key relationships create

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.