I have two Lists - A & B include {time, value}.
List<TimeVal> A = ...;
List<TimeVal> B = ...;
public class TimeVal
{
public DateTime time {get;set;}
public int value {get;set;}
}
How can I find the intersection where A.time == B.time to generate a new List which merges the properties of both C= {time, valueA, valueB} ?
List<TimeBothVals> C = ?
public class TimeBothVals
{
public DateTime time {get;set;}
public int ValueA {get;set;}
public int ValueB {get;set;}
}
Thank you.
答案 0 :(得分:0)
你走了。
List<TimeBothVals> C = (from ai in a
join bi in b on ai.time equals bi.time
select new TimeBothVals
{
time = ai.time,
ValueA = ai.value,
ValueB = bi.value
})
.ToList();