0

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

This is my example .

.

Can anyone help me?

TaW
  • 53,122
  • 8
  • 69
  • 111
John Morison
  • 41
  • 1
  • 5

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
  • 24,430
  • 5
  • 58
  • 85
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,279
  • 5
  • 36
  • 56