string.Replace (or other string modification) not working

前端 未结 4 482
误落风尘
误落风尘 2020-11-22 06:17

For the following code, I can\'t get the string.Replace to work:

someTestString.Replace(someID.ToString(), sessionID);

when I

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 06:51

    You can achieve the desired effect by using

    someTestString = someTestString.Replace(someID.ToString(), sessionID);
    

    As womp said, strings are immutable, which means their values cannot be changed without changing the entire object.

提交回复
热议问题