我是这么写的,不过感觉太笨了=-=,大家有什么好的办法吗?
string[] merge0 = picture0.Concat(picture1).ToArray();
string[] merge1 = picture2.Concat(picture3).ToArray();
string[] merge2 = picture4.Concat(picture5).ToArray();
string[] merge3 = picture6.Concat(picture7).ToArray();
string[] merge4 = picture8.Concat(picture9).ToArray();
string[] merge0_1 = merge0.Concat(merge1).ToArray();
string[] merge2_3 = merge2.Concat(merge3).ToArray();
string[] merge01_23 = merge0_1.Concat(merge2_3).ToArray();
string[] picture = merge01_23.Concat(merge4).ToArray();
6 个解决方案
#1
string.join()
#2
大佬,我在网上只看到合并字符串的例子,大佬方便写下代码吗,或者给个有数组连接例子的链接 :)
#3
picture0.Union(picture1).Union(picture2).ToArray();
#4
string [] picture= picture0.Concat(picture1).Concat(picture2).Concat(picture3)......ToArray();
#5
测试例
string[] a = { "aa", "ba", "da" };
string[] b = { "ab", "bb", "db" };
string[] c = { "ac", "bc", "dc" };
var r = new[] { a, b, c }.Aggregate(new string[]{}, (x, y) => x.Concat(y).ToArray());
Console.WriteLine(string.Join(",", r));
#6
.net 类库里面并没有现成的简洁的方法,不过把你觉得笨的方法写成一个可以重复调用的函数,就变成了一个聪明的方法。
#1
string.join()
#2
大佬,我在网上只看到合并字符串的例子,大佬方便写下代码吗,或者给个有数组连接例子的链接 :)
#3
picture0.Union(picture1).Union(picture2).ToArray();
#4
string [] picture= picture0.Concat(picture1).Concat(picture2).Concat(picture3)......ToArray();
#5
测试例
string[] a = { "aa", "ba", "da" };
string[] b = { "ab", "bb", "db" };
string[] c = { "ac", "bc", "dc" };
var r = new[] { a, b, c }.Aggregate(new string[]{}, (x, y) => x.Concat(y).ToArray());
Console.WriteLine(string.Join(",", r));
#6
.net 类库里面并没有现成的简洁的方法,不过把你觉得笨的方法写成一个可以重复调用的函数,就变成了一个聪明的方法。