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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:01:35+00:00 2026-05-17T03:01:35+00:00

Just a bit rusty on the old linq. If I have 2 collections EG

  • 0

Just a bit rusty on the old linq.
If I have 2 collections EG NewCustomerList and OldCustomerList and see if a surname exists already how would I do it in linq .I am sure there are many ways. SelectMany rings a bell but forgot how to do it!

In a forEach I would do something like that. What is the equivalent in linq?

     foreach (var  oldCustomer in OldCustomerList)
     {
        foreach (var newCustomer in NewCustomerList.Where(x => x.Surname == oldCustomer.Surname))
        {
           break;
        }
     } 

Any Suggestions? Thanks a lot

  • 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-17T03:01:35+00:00Added an answer on May 17, 2026 at 3:01 am

    So you’re trying to see whether any of the old customer surnames are in the new customer list?

    One simple option: do a join and see if it’s empty:

    if (OldCustomerList.Join(NewCustomerList, x => x.Surname, x => x.Surname,
                             (x, y) => null).Any())
    {
        ...
    }
    

    (I’ve used a null projection because we really don’t care about the join result.)

    Another option:

    var oldSurnames = new HashSet<string>(OldCustomrList.Select(x => x.Surname));
    if (NewSurnameList.Any(x => oldSurnames.Contains(x.Surname))
    {
        ...
    }
    

    I suspect you may find that you actually want the result in terms of which surnames are in common though… if you can give us more context, we may be able to help you more.

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

Sidebar

Related Questions

Would love some help here. I'm sure it's simple enough, I'm just a bit
I have windows 7 (64-bit) and just upgraded IE9 in my machine. I did
[I'm sure this is not odd at all, but I need just a bit
I have written a script. It does work! It's just a bit rubbish. Could
I was just a bit bored and was thinking that it would be cool
I'm just a bit CSSing, and I have this code: #page { width: 950px;
Just a bit of idle curiosity here. Basically, if I have an object that
Just a bit of background first. I currently have a site hosted with Windows
On OSX, I have a Python universal binary which just contains 32-bit code: $
I'm pretty new to Android but I have some experience (and a bit rusty

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.