Microsoft Developer Network > Forums Home > Archived Forums Forums > LINQ Project General > Newblie Linq Question - Intersecting to lists on partial matches
Ask a questionAsk a question
 

AnswerNewblie Linq Question - Intersecting to lists on partial matches

  • Thursday, November 05, 2009 4:17 AMwtfChris Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm pretty new with Linq so forgive me if this is one of those "well, duh!" questions.

    I have an IEnumerable<string> where each string represents someone's name in the format Lastname, Firstname.

    I have another IEnumber<string> where each string represents a Last name

    I'd like to get an IEnumerable<string> list of people's name whos last name are in my last names collection.

    For example:

    var LastNames = new [] {"Smith","Jones"}
    var People = new [] {"Smith, Ted", "Jones, Bob", "Jones, Alan", "Kent, Clark"}

    I'd like to end up with a list/array/Ienumerable containing "Smith, Ted", "Jones, Bob", and  "Jones, Alan".

    The intersect operator seems close, but I believe it does full string matching.

    Thanks.

Answers

All Replies