Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace FunctionalProgramming__PredicateForNames
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int namesLenght = int.Parse(Console.ReadLine());
  12.  
  13. string[] names = Console.ReadLine()
  14. .Split(" ", StringSplitOptions.RemoveEmptyEntries)
  15. .ToArray();
  16.  
  17. Predicate<string> rightLenght = name => name.Length <= 4;
  18.  
  19. foreach (var name in names)
  20. {
  21. if (rightLenght(name))
  22. {
  23. Console.WriteLine(name);
  24. }
  25. }
  26.  
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement