How to replace straight quotation mark (")

后端 未结 3 1477
我寻月下人不归
我寻月下人不归 2021-01-04 08:32

I would like to replace a straight quotation mark (\") using C#.

I might be missing something small, but I can\'t get it with a normal string.Replace();

3条回答
  •  一整个雨季
    2021-01-04 09:17

    I agree with Heinzi, you should use " instead of &, and & means "&" Btw, after invoking the Replace method, don't forget to set the value to someWord again:

    someWord = someWord.Replace("\"", """);
    

    And there is another way to do it. Add the reference System.Web, and using System.Web; then:

    someWord = HttpUtility.HtmlEncode(someWord);

提交回复
热议问题