如果不知道位置,如何使用 C# 替换字符串数组中的项目文本?
我的数组是 [berlin, london, paris] 如何用纽约替换巴黎?
最佳答案
需要通过索引来解决:
arr[2] = "new york";
既然你说不知道位置,那你可以用Array.IndexOf找:
arr[Array.IndexOf(arr, "paris")] = "new york"; // ignoring error handling
关于c# - 如何替换字符串数组中的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2349339/