'Join two string lists elements one by one
I have two IEnumerable<string> that I need to combine joining their elements "index by index".
At the moment I'm using a simple foreach statement to merge the elements one by one and add them to a List<string>.
List<string> res = new List<string>();
int index = 0;
foreach (var date in dates)
res.Add(
string.Join(
",",
DateTimeOffset.FromUnixTimeSeconds(long.Parse(date)).ToString("yyyy-MM-dd HH:mm:ss"),
values.ElementAt(index++)
)
);
I was wondering if there is a way to solve this directly in LINQ.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
