Split - Join, Aggregate, Zip, LINQ

aggregate, c#, join, linq, split

Solution

Best method? I am not sure. but I find it a simple way.

string g1 = "A-B-C-D";
string g2 = "W-X-Y-Z";

var result = String.Join("-",g1.Split('-').Zip(g2.Split('-'), (a,b) => a+"-"+b));

EDIT

And to get back

int i=0;
var gs = result.Split('-').GroupBy(_ => i++ % 2).Select(g => String.Join("-",g))
               .ToList();

Problem

1st GUID String: ``` A-B-C-D ``` 2nd GUID String: ``` W-X-Y-Z ``` 3rd Required Reversible String: A-W-B-X-C-Y-D-Z What's the best method to join 1st & 2nd to get 3rd then separate it to get both back? Join-Split, Aggregate, Zip or others? Edit I: Maybe LINQ if every GUID is assumed to be `Enumerable<String>` { A, B, C, D } ?

Original source