tags:

views:

33

answers:

1

Hi, im just writing my own replace method for any weird characters and i used the ASCI value 0, null to replace unwanted characters, i was hoping for them to be 'deleted', but this doesnt work. A gap just appears in the string.

What exactly does String.Replace() do when removing a character for ""? Does it shift them all down and then 'delete' the final character or something?

A: 

Strings are immutable - you cannot change a string. You can only create a new string with the characters removed. If you replace a string with the empty string, you simply create a new string that does not contain the matched characters.

John Saunders
Ah so that explains why you always create a new string with replace()!!!
Tom