TheBulgarianWolf

String Manipulation

Mar 17th, 2021
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System;
  2.  
  3. namespace StringManipulation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string removeWord = Console.ReadLine();
  10.             string text = Console.ReadLine();
  11.  
  12.             int index = text.IndexOf(removeWord);
  13.  
  14.             while(index != -1)
  15.             {
  16.                 text = text.Remove(index, removeWord.Length);
  17.                 index = text.IndexOf(removeWord);
  18.             }
  19.  
  20.             Console.WriteLine(text);
  21.         }
  22.     }
  23. }
  24.  
Add Comment
Please, Sign In to add comment