List of stringbuilders from stringbuilder's lines
hi first post here
i am a little unsure of the code iv'e written as...
im pretty noob with the stringbuilder class
my app will rely on as few gc collections as possible text can be a problem
but i have specific problem were
i need to pull appended lines from a stringbuilder object
put it into a list or array of stringbuilders
keep the original and modify the list elements lengths to shorten them
the real problem is im unsure if this is ok what im doing
or if there is a better way already
public static List<StringBuilder> StringBuilderSplit(StringBuilder sb_text)
{
List<StringBuilder> sb_list = new List<StringBuilder>();
sb_list.Add(new StringBuilder());
char line_break_char = '\n';
if (false == char.TryParse(Environment.NewLine, out line_break_char)) { line_break_char = '\n'; }
//
int sbli = 0;
for (int i = 0; i < sb_text.Length; i++)
{
if (sb_text[i].CompareTo(line_break_char) != 0)
{
sb_list[sbli].Append(sb_text[i]);
}
else
{
sb_list.Add(new StringBuilder());
sbli++;
}
}
return sb_list;
}