Here’s what I have at the moment:
public List<double> GetStrokeDashArray(List<double> dashLengths, double gap)
{
return dashLengths
.SelectMany(dl => new[] { dl, gap })
.Take(dashLengths.Count * 2 - 1)
.ToList();
}
Results for GetStrokeDashArray(new List<double> { 2, 4, 7, 11, 16 }, 2);
2, 2, 4, 2, 7, 2, 11, 2, 16
I think the best way is to create a specific extension method for that:
You can then write your method as follows: