How to remove all instances of a specific character from a string?

后端 未结 3 1343
抹茶落季
抹茶落季 2021-02-06 21:32

I am trying to remove all of a specific character from a string. I have been using String.Replace, but it does nothing, and I don\'t know why. This is my current co

3条回答
  •  猫巷女王i
    2021-02-06 22:14

    Like climbage said, your problem is definitely

    Gamertag2.Replace("^"+1,"");
    

    That line will only remove instances of "^1" from your string. If you want to remove all instances of "^", what you want is:

    Gamertag2.Replace("^","");
    

提交回复
热议问题