3
The goal is to join these two list, being that if in the list pr
have an item that does not match the list un
, the default value will be returned.
I know there are other ways, but I would like solution using DefaultIfEmpty
var pr = new List<int>() { 1, 2, 3 };
var un = new List<int>() { 1, 2 };
var pu = from p in pr.DefaultIfEmpty(new int())
join u in un on p equals u
select p;
foreach (var i in pu)
{
Console.WriteLine(i);
}
Result: 1.2
Expected: 1,2,0