fork(6) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var list = new List<string> {"abcdef", "abc", "ab", "cd ab"};
  11.  
  12. var searchForList = new List<string> { "ab", "abc", "ab cd" };
  13.  
  14. foreach(var searchFor in searchForList)
  15. {
  16. // word must contain all the string in search words
  17. var result = list.Where (w => searchFor.Split().All (s => w.Contains(s)));
  18. Console.WriteLine(string.Format("Searching for \"{0}\":", searchFor));
  19. foreach(var s in result)
  20. {
  21. Console.WriteLine(s);
  22. }
  23. Console.WriteLine();
  24. }
  25. }
  26. }
Success #stdin #stdout 0.05s 37184KB
stdin
Standard input is empty
stdout
Searching for "ab":
abcdef
abc
ab
cd ab

Searching for "abc":
abcdef
abc

Searching for "ab cd":
abcdef
cd ab