C# 将字符串数组复制到C中现有的字符串数组#
现在我想将以下数组复制到上面的search1。换句话说,我想合并两个数组C# 将字符串数组复制到C中现有的字符串数组#,c#,arrays,C#,Arrays,现在我想将以下数组复制到上面的search1。换句话说,我想合并两个数组 String[] search1 = Directory.EnumerateFiles(voiceSource, callId + " "+ separator +"*."+ fileFormat +"") .Where(file => Path.GetFileName(file).StartsWith( callId + " "+ separator +""))
String[] search1 = Directory.EnumerateFiles(voiceSource, callId + " "+ separator +"*."+ fileFormat +"")
.Where(file => Path.GetFileName(file).StartsWith( callId + " "+ separator +""))
.Select(path => Path.GetFileName(path))
.ToArray();
请注意,search1的长度可能为零。有什么帮助吗
String[] search2 = Directory.EnumerateFiles(voiceSource, callId + ""+ separator +"*."+ fileFormat +"")
.Where(file => Path.GetFileName(file).StartsWith(callId + ""+ separator +""))
.Select(path => Path.GetFileName(path))
.ToArray();
其中type是数组中元素的类型
从中,我不太清楚您想要实现什么-您能澄清一下吗?您的意思是只想连接两个数组吗?如果是,请使用LINQ:
a.Concat(b).ToArray()
而不是从另一个答案复制代码,标记为另一个问题的副本。
search3 = new type[search1.Length + search2.Length];
search1.CopyTo(search3, 0);
search2.CopyTo(search3, search1.Length);