If I've understood you right (you want to obtain jagged array string[][]
from ordinal one - string[]
), you can try Linq in order to GroupBy
items into subarrays:
using System.Linq;
...
string[] strarry = new string[]
{"12", "34", "A1", "FE", "12", "34", "EA", "0", "FE"};
// Here we exploit side effects, be careful with them
int groupIndex = 0;
string[][] result = strarry
.GroupBy(value => value == "FE" ? groupIndex++ : groupIndex)
.Select(group => group.ToArray())
.ToArray();
Let's have a look:
string report = string.Join(Environment.NewLine, result
.Select(line => "[" + string.Join(", ", line) + "]"));
Console.Write(report);
Outcome:
[12, 34, A1, FE]
[12, 34, EA, 0, FE]