Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
除了使用以下代码之外,我如何直接将元素附加到数组的末尾。
string[] array = ["1","2"]; array[lengthof-1] = "3";
这是目前唯一可能的方法。
int[] a = [1,2,3,4,5,6]; a[lengthof a] = 7;
目前没有内置的附加功能。
您可以简单地为此创建一个函数。
function append(int[] arr,int val){ arr[arr.length()] = val; }
然后你可以在你的代码中使用它