在字符串数组的每个元素中替换子字符串?
问题描述:
嘿,我有一个字符串数组,我想替换每个这些元素中的某个子字符串.除了显式地迭代数组之外,还有一种简便的方法吗?
Hey, I have an array of strings and I want to replace a certain substring in each of those elements. Is there an easy way to do that besides iterating the array explicitly?
谢谢:-)
答
您可以隐式迭代数组
arrayOfStrings = arrayOfStrings.Select(s => s.Replace("abc", "xyz")).ToArray();