What is the fastest way to section data
<p>I am not sure what this is called so Ill explain by giving an example. I have an array of numbers</p>

<pre><code>76425
234786234
56
4356
564356
456
94
900
725
</code></pre>

<p>Now I would like to join this data and make a new array that looks like this</p>

<pre><code>76425,234786234,56,4356
564356,456,94,900
725
</code></pre>

<p>This is a string array that contains 3 items. Items per row is 4. As you can see the last row only has one item. That is ok. Here is the code I have written to do this:</p>

<pre><code> numberOfColumns = numberOfColumns &gt; lineCount ? lineCount : numberOfColumns;
 int newLineCount = Convert.ToInt32(Math.Ceiling((Convert.ToDouble(lineCount))/numberOfColumns));
 StringBuilder sb = new StringBuilder();

 for (int i = 0; i &lt; newLineCount; i++)
 {
      var page = lines.Skip(numberOfColumns * i).Take(numberOfColumns).Select(xx =&gt; xx.Trim());
      sb.AppendLine(string.Join(",",page));
 }
</code></pre>

<p>This code works just fine. But it is very slow. Do you have any ideas to make it faster.</p>
