I got a list of strings,on which I would like to do an operation which concats each item with rest of the items. The below test fails at the moment, I think the join is not the correct linq method I should be using- can you please let me know how to get this done? The pattern of the output should tell how the projection should be,if not the rule is simple:take one item and concatenate with all the other items and then move to the next item.Test below:
[Test]
public void Should_concatenate_all_items()
{
var items = new List<string> {"a", "b", "c", "d"};
var concatenatedList = items .Join(items , x => x, y => y, (x, y) => string.Concat(x, y));
foreach (var item in concatenatedList)
{
//Should output:ab
//Should output:ac
//Should output:ad
//Should output:bc
//Should output:bd
//Should output:cd
Console.WriteLine(item);
}
}
Note: I'm using .NET 3.5.