title: In C#, how can I filter a list using a StartsWith() condition of another list?
body: <p>Lets say I have a list of strings:</p>
  
  <pre><code>var searchList = new List&lt;string&gt;();
  searchList.Add("Joe"):
  searchList.Add("Bob");
  </code></pre>
  
  <p>and I have another list</p>
  
  <pre><code>var fullNameList = new List&lt;string&gt;();
  fullNameList.Add("Joe Thompson"):
  fullNameList.Add("Bob Jones");
  fullNameList.Add("Bob Smith");
  fullNameList.Add("Billy Smith");
  fullNameList.Add("Joe Williams");
  </code></pre>
  
  <p>I now want to filter the fullNameList based on if it exists in the search list but I am not doing a direct match but rather a "starts with" match.  So in my example, after filtering I would want this to be the results</p>
  
  <pre><code>"Joe Thompson"
  "Bob Jones"
  "Bob Smith"
  "Joe Williams"
  </code></pre>
  
  <p>(as you can see the record starting with Billy was not included as it didn't start with any items in the search list)</p>
  
  <p>I could do this "manually" like this:</p>
  
  <pre><code> var resultList = fullNameList.Where(r=&gt; r.StartsWith("Joe") || r.StartsWith("Bob"));
  </code></pre>
  
  <p>but I want it to be dynamic (as there might be more items in the search list added in the future).  </p>
  
  <p>I could do this in a loop like this:</p>
  
  <pre><code> var resultsList = new List&lt;string&gt;();
  
   foreach (var item in searchList)
   { 
        resultsList.AddRange(fullNameList.Where(r=&gt;r.StartsWith(item));
   } 
  </code></pre>
  
  <p>but wanted to see if there anyway to do a Startswith on a list as opposed to a single string in a single line of linq code?</p>