fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var foulWords = new List<string>(){"cat", "dog", "mouse", "Nice animal"};
  10. var phrases = new List<string>(){"A cat is good", "a dog is bad", "cat and dog are good", "Nice animal", "Hello", "Hello mouse", "This is bad"};
  11. int contains = phrases.Count(p => foulWords.Any(fw => p.Contains(fw)));
  12. Console.WriteLine("Phrases contain Foulwords {0} times", contains);
  13. }
  14. }
Success #stdin #stdout 0.05s 34120KB
stdin
Standard input is empty
stdout
Phrases contain Foulwords 5 times