I have a list (of objects), with one property in the object as a string.
This property always contains single words and would like to loop through all sequential combinations in pairs, for example:
- word1
- word2
- word3
- word4
- word5
I am trying to write LINQ which will allow me to iterate through the data in the following format:
- word1 [space] word2
- word2 [space] word3
- word3 [space] word4
- word4 [space] word5
Could anybody suggest the most efficient way of doing this.
I have a bunch of conditional IF statements at the moment that I’m looking to remove.
I think you want:
That’s assuming you’re using .NET 4, which is when
Zipwas introduced.