elena1234

CountUppercaseWords- how to use the delegate Func< >

Jan 21st, 2021 (edited)
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace CountUppercaseWords
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var text = Console.ReadLine();
  11.             Func<string, bool> func = x => char.IsUpper(x[0]);
  12.             var words = text.Split(" ",StringSplitOptions.RemoveEmptyEntries).Where(x => func(x));
  13.             Console.WriteLine(string.Join(Environment.NewLine,words));                  
  14.         }
  15.     }
  16. }
  17.  
Add Comment
Please, Sign In to add comment