0

I try label1.Text.Remove(1,2); but it doesn't work.

This is my example .

.

Can anyone help me?

TaW
  • 50,936
  • 8
  • 63
  • 99

2 Answers2

4

Remove returns new string, does not modify current one, so you need to assign it to label:

label1.Text = label1.Text.Remove(1,2);
Backs
  • 23,679
  • 4
  • 50
  • 77
1

label1.Text is a string and strings are immutable (they cannot change). Think of it as an array of chars. You can't resize arrays without asking for new memory.

string.Remove returns a new, modified string. Simply do label1.Text = label1.Text.Remove(1,2);

Philippe Paré
  • 4,134
  • 5
  • 31
  • 53