日期:2014-05-17 浏览次数:20835 次
string[] arr1 = new string[] { "a", "b", "c", "d", "e", "f", "g", "h" };
string[] arr2 = new string[] { "1", "2", "3", "4"};
var v = arr1.Select((x, i) => x + arr2[i % arr2.Length]);
foreach(string s in v)
{
MessageBox.Show(s);
}
void Main()
{
var list1=new string[]{"a", "b", "c", "d", "e", "f", "g", "h"};
var list2=new int[]{1, 2 ,3 ,4};
var query=from l1 in list1.Select((x,y)=>new {x,y})
join l2 in list2.Select((x,y)=>new {x,y})
on l1.y%list2.Count() equals l2.y%list2.Count()
select l1.x +","+l2.x;
query.ToList().ForEach(q=>Console.WriteLine(q));
/*
a,1
b,2
c,3
d,4
e,1
f,2
g,3
h,4
*/
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1