MiroslavKisov

PredicateForNames

Feb 5th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace PredicateForNames
  5. {
  6.     public class Program
  7.     {
  8.         public static void Main()
  9.         {
  10.             int nameLenght = int.Parse(Console.ReadLine());
  11.             var names = Console.ReadLine()
  12.                 .Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)
  13.                 .ToArray();
  14.             Func<string, bool> filter = n => n.Length <= nameLenght;
  15.             names = names.Where(filter).ToArray();
  16.             foreach (var name in names)
  17.             {
  18.                 Console.WriteLine(name);
  19.             }
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment