This code is available:

for (int item = 0; item < Mass.Length; item++) { if (Mass[item].Remove(0, Mass[item].Length - 2) == "ed" || Mass[item].Remove(0, Mass[item].Length - 2) == "ED") { Mass[item] = Mass[item].Remove(Mass[item].Length - 2, 2) + "ing"; } label3.Text = Convert.ToString(Mass[item]); } 

When executed, only the last completed operation is displayed on the field. What to change, what would be displayed all the elements of the array? For example: Extand mixed rule pasted -> Extand mixing rule pasting

  • Add "+" to the last line: label3.Text + = Convert.ToString (Mass [item]); - Vladimir Zhukov
  • Displays error: goo.gl/tNEiZe - Dmitriy

1 answer 1

The problem is that you reassign the value of the text in the label at each iteration of the cycle. Take out the installation for the cycle:

 for (int item = 0; item < Mass.Length; item++) { if (Mass[item].Remove(0, Mass[item].Length - 2) == "ed" || Mass[item].Remove(0, Mass[item].Length - 2) == "ED") { Mass[item] = Mass[item].Remove(Mass[item].Length - 2, 2) + "ing"; } } // склеиваем слова в строчку, слова будут разделены пробелом label3.Text = string.Join(" ", Mass); 

Moreover, your word completion check can be simplified:

 for (int item = 0; item < Mass.Length; item++) { if (Mass[item].EndsWith("ed", StringComparison.InvariantCultureIgnoreCase)) { Mass[item] = Mass[item].Remove(Mass[item].Length - 2, 2) + "ing"; } } // склеиваем слова в строчку, слова будут разделены пробелом label3.Text = string.Join(" ", Mass); 
  • Thank! How to remove this part now: goo.gl/0AqJp4 ? - Dmitriy
  • @Dmitry: This is the next question, ask it separately. Is this all clear? - VladD
  • Yes. Everything is clear - Dmitry
  • @ Dmitriy can then mark as correct (tick next to the answer). - andreycha