I am using a StringBuilder object and would like to get (read, not remove) a couple of characters from it. However, StringBuilders do not support methods like substring2(). I know that I can convert a StringBuilder object with ToString, but that may be expensive (in terms of time and memory), as the StringBuilder object may get quite large. Is my assumption correct that in a coding like
the whole SB gets converted to a string before substring copies the relevant characters from it? Or is the compiler "intelligent" and converts only the requested characters (30000 to 30007)?
If not, how to go about reading only a few characters from a StringBuilder without the need to temporarily take away a lot of memory? Maybe I should use something like an array of bytes or chars? But I need the thing to be able to grow without losing information (as the re-dimming of an array would entail).
Thanks.
Regards,
B4X:
dim a as string
a = SB.ToString.Substring2(30000,30007) ' SB is the StringBuilder
the whole SB gets converted to a string before substring copies the relevant characters from it? Or is the compiler "intelligent" and converts only the requested characters (30000 to 30007)?
If not, how to go about reading only a few characters from a StringBuilder without the need to temporarily take away a lot of memory? Maybe I should use something like an array of bytes or chars? But I need the thing to be able to grow without losing information (as the re-dimming of an array would entail).
Thanks.
Regards,
Last edited: