Copy one string array to another

前端 未结 3 578
遇见更好的自我
遇见更好的自我 2020-12-30 01:13

How can I copy a string[] from another string[]?

Suppose I have string[] args. How can I copy it to another array string

3条回答
  •  自闭症患者
    2020-12-30 02:13

    Allocate space for the target array, that use Array.CopyTo():

    targetArray = new string[sourceArray.Length];
    sourceArray.CopyTo( targetArray, 0 );
    

提交回复
热议问题