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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:26:33+00:00 2026-05-20T21:26:33+00:00

i think this question has been asked before but i havent been able to

  • 0

i think this question has been asked before but i havent been able to deduce a clear answer. I am trying to find the best way (or a way) to intersect two completely different ienumerable collections.

class A:

  • int z1
  • int z2
  • int z3
  • string z4

class B:

  • int j5
  • int j6
  • T j7
  • T j8
  • string j9

..I want to intersect List<A> with List<B> on z2 == j6.

can this be done?

  • 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-20T21:26:34+00:00Added an answer on May 20, 2026 at 9:26 pm

    The question doesn’t really make sense – what would the result type be? Intersections have to be performed on two sequences of the same type. It sounds like you don’t so much want an intersection between two sets, as a filter of the first sequence based on possible values of z2. For example:

    HashSet<int> validZ2 = new HashSet<int>(listB.Select(x => x.j6));
    var filtered = listA.Where(x => validZ2.Contains(x.z2));
    

    Or possibly as Gabe suggests, you want a join. For example:

    var query = from a in listA
                join b in listB on a.z2 equals b.j6
                select new { a, b };
    

    That will give you all pairings of values from the two lists which match on z2/j6.

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

Sidebar

Related Questions

I know this question has been asked here before, but I don't think those
I realize this has been asked before, but I wasn't able to find a
I know this is a question that has been asked before, but I think
(I think this question has been asked before, but the answers have been contradictory
I'm sure this question has been asked before, but I can't seem to find
probably this question has been asked in many forms before but still I think
This question has to have been asked before, but I think the search terms
I don't think this question has been asked before. I'm a bit confused on
This question has been asked before, but I would like a little more detail
I know this sort of question has been asked before , but I still

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.