0

I have a customer List and a string List where each string is like "blah;huhu";

I want to get all customers whose name is in the last part of the splitted "blah;huhu"

like c.Name == "huhu".

Thats my pseudo code:

String ID = 1000;

var query = customerListWithIdAndName.Where(
    c => c.Name == stringListWith2SemicolonSeparatedStrings.Split().Last()
);

What would be the correct code that I can make a comparison on EACH splitted value?

UPDATE:

I want for every returned customer to assign a value: String ID = 1000; Thus every customer returned must have the id 1000.

Elisabeth
  • 20,496
  • 52
  • 200
  • 321
  • 1
    you want *I want to get all customers whose name is in the last part of the splitted "blah;huhu"* and *What would be the correct code that I can make a comparison on EACH splitted value*? that's confused – cuongle Oct 25 '12 at 10:21

1 Answers1

1

Now that I get what you want, this should do it:

var query = customerListWithIdAndName.Where(c =>
   stringListWith2SemicolonSeparatedStrings.Any(
       p => p.Split().Last() == c.Name));
Sandor Drieënhuizen
  • 6,310
  • 5
  • 37
  • 80