c# string.replace in foreach loop

后端 未结 5 1731
长发绾君心
长发绾君心 2021-02-07 14:01

Somehow I can\'t seem to get string replacement within a foreach loop in C# to work. My code is as follows :

foreach (string s in names)
{
    s.Replace(\"pdf\"         


        
5条回答
  •  我寻月下人不归
    2021-02-07 14:57

    s.Replace is a function so you would like s=s.Replace().. although it's better to use StringBuilder. (see upper answer)

提交回复
热议问题