This will create the jagged array:
Dim myArray = (From row In myStringBuilder.ToString().Split({vbCrLf}, StringSplitOptions.None)
Select (From col In row.Split(","c)
Select col
).ToArray()
).ToArray()
Explanation:
- First, we convert the StringBuilder to a String:
myStringBuilder.ToString()
- Then we split on line breaks:
Split({vbCrLf}, StringSplitOptions.None)
. Since a line break consists of two characters in Windows, we use theSplit
overload that accepts a string array (hence the braces). - Within the row we split the line on commas:
Split(","c)
. Thec
specifies that this is a character instead of a string. - Finally, we convert this enumerable of enumerables into an array of arrays by applying
ToArray
to the outer as well as the inner LINQ expression.