public static int GetCountOfWords(string sentence)
if(string.IsNullOrEmpty(sentence))
var result = sentence.Replace("the", string.Empty);
string[] resultArray = result.Split(new string[] {" "}, StringSplitOptions.RemoveEmptyEntries);
return resultArray.Length;
public static void Main(string []args)
Console.WriteLine(GetCountOfWords("The quick brown fox jumps over the lazy dog"));