Advertisement
elena1234

SubstringWithRemove()

Nov 12th, 2020 (edited)
170
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. using System.Text;
  3.  
  4. namespace Substring
  5. {
  6.     class MainClass
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.           string wordToRemove = Console.ReadLine().ToLower();
  11.           string text = Console.ReadLine();
  12.             while (text.Contains(wordToRemove))
  13.             {
  14.               int startIndex = text.IndexOf(wordToRemove);
  15.               text = text.Remove(startIndex,wordToRemove.Length);
  16.             }
  17.  
  18.           Console.WriteLine(text);
  19.         }
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement