首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

仍是数组拼接

2012-11-03 
还是数组拼接C# codeListstring one new Liststring{0101,0202}Liststring target new Lis

还是数组拼接

C# code
List<string> one = new List<string>{"0101","0202"};List<string> target = new List<string>{"0505","0606","0707","0808","0909"};


我希望得到的结果是

01010505
01010606
01010707
01010808
01010909

02020505
02020606
02020707
02020808
02020909

我这样写的

C# code
for (int i = 0; i < one.Count; i++){    for (int n = 0; n <= 4; n++)    {         target[n].Union(one[i]);//没有出现红线,但没有效果         grp[n].Concat(dan[i]);//出现红线     }}


[解决办法]
C# code
one.ForEach(o => {    target.ForEach(t => {        Console.WriteLine(o + t);    });});
[解决办法]
C# code
var result = from o in one from t in target select (o+t);foreach (var i in result) Console.WriteLine(i);/*01010505010106060101070701010808010109090202050502020606020207070202080802020909*/ 

热点排行