If you're looking for a Substring
alternative that doesn't extract the entire string from the StringBuilder
you could use the overload of ToString
that takes a start
and length
:
string header;
foreach(StringBuilder strBuilder in bigArray)
{
header= strBuilder.ToString(start, length);
}
Is it faster? I don't know - you'll have to measure it to know for sure.
Another alternative would be to store the "lines" as a collection of string arrays (or List<List<string>>
) rather than a collection of StringBuilder
s.