title: How do I find the occurrences of a given word in a sentence?
body: <p>Here is the code for finding the number of occurrence of a given word in a sentence.</p>
  
  <pre><code>static void Main(string[] args)
  {
      string str;
      string word;
      int count = 0;
      str = Console.ReadLine();
      word = Console.ReadLine();
      string[] str1 = str.Split(' ','.');
      for (int i = 0; i &lt; str1.Length; i++)
      {
          if (str1[i].Equals(word))
          {                   
              count++;
          }                       
      }
      Console.WriteLine("No of occurrence of a word:" +count);
      Console.ReadLine();
  
  }
  </code></pre>
  
  <p>Is there any best and optimized way to code this..?</p>