Suppose I have two Lists<myObject>
where myObject
consists of the two properties
Id (of type Int
) and
Value (of type Double
)
I need to get a list out of these two lists that is made of (anonymous) objects like this:
Id, [Double value from List 1], [Double value from List 2]
So if for a given Id both lists contain a value, it should look like this example:
12, 21.75, 19.87
If one list does not contain an object with an Id that is present in the other list, the value should be null:
15, null, 22.52
How can I achieve that? Update: I know how I could get such a list, of course, but I'm looking for the most performant way to do it, preferrably by using some witty Linq magic.