title: c# "like/contains" search through a list
body: <pre><code>        query = Files
              .Where(file =&gt; file.Fileinfo.Name.ToUpper().Contains(textBox1.Text.ToUpper()))
              .Take(7).ToList();
  </code></pre>
  
  <p>I hate asking this question, but I am simply not having any progress! It should seem like a trivial task, but I am not having any luck.</p>
  
  <p>The above query needs to do a search through a list of filenames. It will return the search results in a list with the top 7 most related results. The event happens at "<code>KeyPress</code>".</p>
  
  <p>Although, it is extremely unprecise and there is also happening some quite odd results.</p>
  
  <p>Forexample: one if the items in my list has the name: "<code>ZeroWidthSplit</code>"
  If my textbox contains "<code>Z</code>", it works. If it contains <code>ZE</code> it works. If it contains "<code>ZER</code>" it still shows.
  If I type <code>ZERO</code> it disappears from the search results!</p>
  
  <p>So I guess my question is: How do you search through a list of files, and make it return the top 7 most related results.</p>
  
  <p>Oh and if there is only 4 related results, that is fine too. The limit is just 7.</p>
  
  <p><strong>Another example:</strong></p>
  
  <p>F.x if I write "<code>sum of</code>" as search query. It returns:</p>
  
  <ol>
  <li>77 - sum of primes five thousand
  different ways</li>
  <li>52  sum of consecutive primes below
  1 million</li>
  </ol>
  
  <p>If I write "<code>sum of p</code>" it returns:</p>
  
  <ol>
  <li>77 - sum of primes five thousand
  different ways</li>
  </ol>
  
  <p>If I write "<code>sum of c</code>" it returns nothing...</p>
  
  <p>I can give you a lot more weird examples.</p>