My code is as below , the usage of this code is to merge 2 list together. and replace its value from one to another.
(from L1 in List1
join L2 in List2
on L1.itemID equals L2.itemID
select L1.itemName= L2.itemName).ToArray();
The code above work perfectly but only for selecting a single attribute which is itemName , how should I write the code if I want to select more than 1 value ,
e.g
(from L1 in List1
join L2 in List2
on L1.itemID equals L2.itemID
select {L1.itemName= L2.itemName , L1.ItemQuantity = L2.Quatity}).ToArray();
You could directly use the property names, as shown below.
The returning array would contain objects with the same Properties itemID
and itemName
.
var outp = (from L1 in List1
join L2 in List2
on L1.itemID equals L2.itemID
select new { L1.itemID, L2.itemName }).ToArray();
Sample Output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With