Replace multiple words in string

后端 未结 8 1127
独厮守ぢ
独厮守ぢ 2020-12-18 19:02

I have multiple words I want to replace with values, whats the best way to do this?

Example: This is what I have done but it feels and looks so wrong



        
8条回答
  •  情话喂你
    2020-12-18 19:22

    You can chain the Replace operations together:

    s = s.Replace(...).Replace(...);
    

    Note that you don't need to create other strings to do this.

    Using String.Format is the appropriate way, but only if you can change the original string to suit the brace formatting.

提交回复
热议问题