textbox replace text

c#

Solution

The `Replace` method returns a string because strings themselves are immutable. This means that instead of changing the existing string (`txtCS.Text`), it creates a new string object and so you need to assign that new string object to the textbox.

Also, you're missing the escape character in your quotes. By adding a `\`, you can use the `"` character, otherwise the compiler thinks you're closing the string.

txtCS.Text = txtCS.Text.Replace("'", "\""); 

Problem

It give me an error, don't know why. I want to replace `'` with `"`. ``` try { txtCS.Text.Replace("'", """); } catch { } ```

Original source