Suppose I have these two arrays
var a = new[] { "a", "b" };
var b = new[] { "1", "2", "3" };
I'm looking for a clever way (using linq or a custom linq extension method) to produce this set of results:
a b 1 2 3
a 1 b 2 3
1 a b 2 3
a 1 2 b 3
1 a 2 b 3
1 2 a b 3
a 1 2 3 b
1 a 2 3 b
1 2 a 3 b
1 2 3 a b
So I'd like to produce all the possible concatenations of fragments of both arrays without changing the order within the fragments.
Does anybody have a good idea how to implement this, maybe by using a recursive approach?
Thanks!