Copy one string array to another(将一个字符串数组复制到另一个)
问题描述
如何从另一个 string[]
复制 string[]
?
How can I copy a string[]
from another string[]
?
假设我有 string[] args
.如何将其复制到另一个数组 string[] args1
?
Suppose I have string[] args
. How can I copy it to another array string[] args1
?
推荐答案
为使用Array.CopyTo()的目标数组分配空间:
Allocate space for the target array, that use Array.CopyTo():
targetArray = new string[sourceArray.Length];
sourceArray.CopyTo( targetArray, 0 );
这篇关于将一个字符串数组复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!