string.Replace() doesn't update the string

后端 未结 1 2029
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 23:40

I tried use the string.Replace() function, but it doesn\'t work right.

string test = \"AAA AA AA faseffs AEfAfse AFAEf AEFAEf\";
test.Replace(\'A\', \'C\');
labe         


        
1条回答
  •  深忆病人
    2021-01-26 00:01

    Strings are immutable in NET. Replace works building a new string with the replaced chars and returning it. You could assign the returned string to the same string used to call the Replace method (or to a new string variable)

    test = test.Replace('A', 'C');
    

    0 讨论(0)
提交回复
热议问题