title: Count how many times a "name" and "surname" is in a text in c# visual studio
body: <p>I want to be able to count a name and surname in C# with visual studio. Currently I can only search for 1 word in the text. I'm creating console applications using .NET 5.0 (current).</p>
  <p>(When the input is &quot;Harry&quot; it counts how many times Harry has been found, when the input is &quot;Harry Potter&quot; it always counts as 0 even when there are multiple occurrences of &quot;Harry Potter&quot; in the text.)</p>
  <p>Ive been looking for answers on google but can only find how to do count 1 word.</p>
  <p>Here's my current code:</p>
  <pre><code>using System;
  using System.IO;
  
  namespace Harry
  {
      class Program
      {
          static void Main(string[] args)
          {
              string input = Console.ReadLine();
              StreamReader stream = File.OpenText(&quot;Harry Potter and the Sorcerer.txt&quot;);
              string text = stream.ReadToEnd();
  
              string woord = &quot;&quot;;
              int count = 0;
  
              foreach (var item in text)
              {
                  if (Char.IsLetter(item))
                  {
                      woord = woord + item;
                  }
                  else
                  {
                      if(woord == input)
                      {
                          count++; 
                      }
                      woord = &quot;&quot;;
                  }
              }
              Console.Write(input + &quot;: &quot; + count + &quot; occurrences&quot;);
          }
      }
  }
  </code></pre>