Split stringbuilder in array

A

Arjen

Hi,

How can I split a stringbuilder into arrays?

Let's say I have a stringbuilder with this value "test1234567".
Now I want an array with size 6. The value of the array have to be on index
0 "234567" and on index 1 "test1".

How can I do this?

Thanks!
 
J

Jon Skeet [C# MVP]

Arjen said:
How can I split a stringbuilder into arrays?

Let's say I have a stringbuilder with this value "test1234567".
Now I want an array with size 6. The value of the array have to be on index
0 "234567" and on index 1 "test1".

What's meant to determine where the string is split? I suggest you call
ToString and then Substring...
 
G

Guest

You could loop thru each character in the Stringbuilder and fill each array
based on the current index in the loop.

Or you could call .ToString() on the stringbuilder and use the IndexOf or
Substring or whatever String functions you needed.
 
K

Kevin Spencer

You can't split a Stringubilder. You CAN split the string it builds. The
string it builds can easily be obtained by calling ToString() on the
StringBuilder. Then you can chop it up anyway you like.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top