redSkywalker

лямбда3

Mar 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace лямбда3
  8. {
  9.     class Program
  10.     {
  11.         delegate string Proccessor(string input);
  12.  
  13.         static void Main()
  14.         {
  15.             Proccessor[] proccessors =
  16.             {
  17.                 (input) => input.ToLower(),
  18.                 (input) => input.Replace("dick", "****"),
  19.                 (input) => input.Replace(" ", "_")
  20.                 /*лямбда которая заменяет пробелы на нижнее подчёркивание*/
  21.             };
  22.  
  23.             string text = Console.ReadLine();
  24.             foreach(Proccessor i in proccessors)
  25.             {
  26.                 text = i(text);
  27.             }
  28.             Console.WriteLine(text);
  29.             Console.ReadKey();
  30.             //прогонка текста через все лямбды и вывод итогового результата
  31.             //на вводе "My dick is big" вывод "my_****_is_big"
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment