将一个字符串数组复制到另一个 [英] Copy one string array to another

查看:32
本文介绍了将一个字符串数组复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从另一个 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 );

这篇关于将一个字符串数组复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆