日期:2014-05-20 浏览次数:20893 次
var result=from x in list1.Select((a,i)=>new {a,i})
join y in list2.Select((a,i)=>new {a,i})
on x.i equals y.i into t
from y in t.DefaultIfEmpty()
select new {key=x.a,value=y==null?"":y.a};
var list1 = new List<string>() { "AA","BB",};
var list2 = new List<string>() { "Q"};
new { key="AA",Value="Q"}
new { key="BB",Value=""}
var list1 = new List<string>() { "AA", "BB", "CC" };
var list2 = new List<string>() { "Q", "X", "V" };
var vs = list1.Select((v, i) => new { v, value = list2[i] });
foreach (var v in vs)
{
MessageBox.Show(v.v+":"+v.value);
}
easy..
var result=from x in list1.Select((a,i)=>new {a,i})
join y in list2.Select((a,i)=>new {a,i})
on x.i equals y.i
select new {key=x.a,value=y.a};
var list1 = new List<string>() { "AA", "BB", "CC" };
var list2 = new List<string>() { "Q", "X", "V" };
var dicquery = from l1 in list1
from l2 in list2
where list1.IndexOf(l1) == list2.IndexOf(l2)