Given the following two strings:
Dim str1() As String = {"123", "456", "789", "0"}
Dim str2() As String = {"123", "456", "1"}
How do I perform a full outer join of str1 and str2 and end up having a structure like this:
{Nothing, "1"}
{"0", Nothing}
{"123", "123"}
{"456", "456"}
{"789", Nothing}
Based on several discussions on SO and other websites, I tried using LINQ:
Dim v = From a In str1 Join b In str2 On a Equals b Group By a Into g = Group
From o In g.DefaultIfEmpty()
But it does not produce the desired result, which is exactly the same as this (regular INNER JOIN):
Dim v = From a In str1 Join b In str2 On a Equals b
The last example I’ve been looking at is here (C#).
And here is Another article, but it seems too complicated to be the shortest possible solution (I’ve seen much more simple C# examples and hope VB can be as efficient).
Why this question is useful
For example, one can have a file structure, where file path is a key. By doing full outer join of the keys, you can compare folders, find which files are missing on which side and show difference to the user. Any kind of synchronization task could use this approach.
I guess this is not the solution you desire, however it seems to fullfil the task:
The output is: