将项添加到数组
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将项添加到数组相关的知识,希望对你有一定的参考价值。
There may be a simpler way to do this but this is the only way I could find to solve this problem. There is no Add method for basic arrays.
// Add an item to the end of an existing array // create a temporary array with an extra slot // at the end // add the contents of the ar1 to ar2 // at position 0 ar1.CopyTo(ar2, 0); // add the desired value ar2.SetValue("Code.", ar1.Length); // overwrite ar1 with ar2 and voila! // the contents of ar1 should now be {"I", "Like", "To", "Code."} ar1 = ar2;
以上是关于将项添加到数组的主要内容,如果未能解决你的问题,请参考以下文章
无法将项添加到const char * vector中? C ++