split with no char

  • Thread starter Thread starter Maarten
  • Start date Start date
M

Maarten

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.
 
Maarten said:
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.
 
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
 
Maarten said:
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 = original.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...
 
Back
Top