Med*_*000 1 .net c# arrays string c#-2.0
可能重复:
在.NET中合并两个数组
如何在C#中连接两个数组?
我怎么能合并两个string[]变量?
例:
string[] x = new string[] { "apple", "soup", "wizard" };
string[] y = new string[] { Q.displayName, Q.ID.toString(), "no more cheese" };
Run Code Online (Sandbox Code Playgroud)
我想添加这两个,所以内容x是:{"apple", "soup", "wizard",Q.displayName, Q.ID.toString(), "no more cheese"};按顺序.这可能吗?如果结果必须进入一个很好的新字符串数组; 我只是想知道如何实现它.
Str*_*ior 10
从这个答案:
var z = new string[x.length + y.length];
x.CopyTo(z, 0);
y.CopyTo(z, x.length);
Run Code Online (Sandbox Code Playgroud)