471,306 Members | 1,226 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

split with no char

Hi all

i'm trying to split a string without a separator
example:

0011010 =

s(1) = 0
s(2) = 0
s(3) = 1
s(4) = 1
s(5) = 0
s(6) = 1
s(7) = 0

s there a way to fix this

regards maarten.
Dec 30 '05 #1
3 1948
Maarten <gu******@hotmail.com> wrote:
i'm trying to split a string without a separator
example:

0011010 =

s(1) = 0
s(2) = 0
s(3) = 1
s(4) = 1
s(5) = 0
s(6) = 1
s(7) = 0

s there a way to fix this


I suspect that the ToCharArray() method is what you're after. If it's
not, if you could give more information it would help.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 30 '05 #2
Hi thanx for the reply

normaly i split an array like this

0,0,1,1,0,1,0

and i use the , to split the array and plase it in a string
string[] s = strvalues.Split(new char[1]{','});

but in this case ther is no comma in the string

--> 0011010

how do i split this one?

regards Maarten

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Maarten <gu******@hotmail.com> wrote:
i'm trying to split a string without a separator
example:

0011010 =

s(1) = 0
s(2) = 0
s(3) = 1
s(4) = 1
s(5) = 0
s(6) = 1
s(7) = 0

s there a way to fix this


I suspect that the ToCharArray() method is what you're after. If it's
not, if you could give more information it would help.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Dec 30 '05 #3
Maarten <gu******@hotmail.com> wrote:
Hi thanx for the reply

normaly i split an array like this

0,0,1,1,0,1,0

and i use the , to split the array and plase it in a string
string[] s = strvalues.Split(new char[1]{','});
Just for future convenience - you don't need to explicitly create the
array. You can use:

string[] s = strvalues.Split(',');
but in this case ther is no comma in the string

--> 0011010

how do i split this one?


Well, ToCharArray will give you each of the characters. If you need to
convert those to strings instead, I *suspect* you'll have to do that
manually. It wouldn't take much to do though:

static string[] ToStringArray(string original)
{
string[] ret = new string[original.Length];

for (int i=0; i < ret.Length; i++)
{
ret[i] = original[i].ToString();
}
return ret;
}

I can't test this at the moment unfortunately, as my computer seems to
be having a bit of a strop at me...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 30 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Henry Chen | last post: by
9 posts views Thread by Java and Swing | last post: by
5 posts views Thread by Vamsi | last post: by
6 posts views Thread by andrewcw | last post: by
7 posts views Thread by lgbjr | last post: by
1 post views Thread by mdefoor | last post: by
4 posts views Thread by mjbauer95 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.