且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何替换字符串数组中的项?

更新时间:2023-02-21 17:15:05

您需要通过指数来解决这个问题:

You need to address it by index:

arr[2] = "new york";

既然你说你不知道的位置,你可以使用Array.IndexOf找到它:

Since you say you don't know the position, you can use Array.IndexOf to find it:

arr[Array.IndexOf(arr, "paris")] = "new york";  // ignoring error handling