fr0stn1k

C#INFO

Feb 12th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Net;
  7. using System.Threading;
  8. using System.IO;
  9.  
  10. namespace IMJunior
  11. {
  12.     class Program
  13.     {
  14.         static void Main()
  15.         {
  16.             string[] list = { "Хуй", "Жопа", "Кевин Спейси" };
  17.             string text = "В голивуде прошёл слух, что Кевин Спейси что-то сделал";
  18.  
  19.             text = Filter(text, list);
  20.             string line = GenerateString(Console.WindowWidth, "-");
  21.             WriteColorLine(line);
  22.             WriteColorLine(text, ConsoleColor.Yellow);
  23.             WriteColorLine(line);
  24.         }
  25.  
  26.         static string Filter(string text, string[] blackList)
  27.         {
  28.             for(int i = 0; i < blackList.Length; i++)
  29.             {
  30.                 text = text.Replace(blackList[i],
  31.                                     GenerateString(blackList[i].Length));
  32.             }
  33.             return text;
  34.         }
  35.  
  36.  
  37.         static string GenerateString(int length, string fuller = "#")
  38.         {
  39.             if (fuller.Length == 0)
  40.             {
  41.                 return "";
  42.             }
  43.  
  44.             string mask = "";
  45.             for (int j = 0; j < length; j += fuller.Length)
  46.             {
  47.                 mask += fuller;
  48.             }
  49.  
  50.             mask = mask.Substring(0, length);
  51.  
  52.             return mask;
  53.         }
  54.  
  55.         static void WriteColorLine(string message, ConsoleColor color = ConsoleColor.Red)
  56.         {
  57.             ConsoleColor old = Console.ForegroundColor;
  58.             Console.ForegroundColor = color;
  59.             Console.WriteLine(message);
  60.             Console.ForegroundColor = old;
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment