Advertisement
silvana1303

substring

Jul 21st, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace mid_exam
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.  
  12.             string wordToFind = Console.ReadLine().ToLower();
  13.             string sentence = Console.ReadLine();
  14.  
  15.  
  16.             while (sentence.Contains(wordToFind))
  17.             {
  18.                 int index = sentence.IndexOf(wordToFind);
  19.                 sentence = sentence.Remove(index, wordToFind.Length);
  20.             }
  21.  
  22.             Console.WriteLine(sentence);
  23.         }  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement