C# string replacement , not working

后端 未结 6 1557
悲哀的现实
悲哀的现实 2020-12-07 03:47

I have a string which I read in from :

TextReader tr = new StreamReader(this.dataPath );
string contents = tr.ReadToEnd(); 

The value of co

6条回答
  •  死守一世寂寞
    2020-12-07 04:46

    System.String is immutable. Operations such as Replace return a new string rather than modifying this string. Use System.Text.StringBuilder if you truly need a mutable string or just assign the result of the Replace call to a variable.

提交回复
热议问题