string slovo = Console.ReadLine ();

Console.WriteLine(slovo.Split(' ').Length); string slovo2= slovo.Split(' ').Last(); string slovo1 = slovo.Split()[0]; slovo = slovo.Trim(); string text = slovo.Remove(slovo1, slovo2); Console.WriteLine( text ); 

slovo1 front word in line

slovo2 back word per line. Question: How to remove slovo1 and slovo2 if it is a string and not an int?

  • string.Replace ? - tym32167
  • no slovo.Remove - Andrew

1 answer 1

Remuv simply deletes the substring starting from a specific index. That is, to remove a word at the end of a line, you need to write an index that begins this word:

  // ... семистрочная строка string test1 = "0123456"; // ... Начать удаление с 4го символа включительно string result1 = test1.Remove(3); // ... Показать "012" Console.WriteLine(result1); 

But it is better to use ripple

slovo.Replace ("Replace me", "");