473,376 Members | 1,079 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,376 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 2020
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Henry Chen | last post by:
Hi, I have a string that needs to be parsed into the string. The separator is not char. It is something like " at ". With current string.Split function, it doesn't work. Is there any exist...
9
by: Java and Swing | last post by:
Say I have a string which contains numbers separated by a comma... such as "0,1,2,3,4,5"...I want to split the string at the commas and return an array containing, 0,1...5. Suggestions? I've...
5
by: Vamsi | last post by:
Hi, I am trying a basic opearation of splitting a multiline value to an array of single lines(Actually making Address into AddressLine1, AddressLine2). I used Environment.NewLine in split, I...
6
by: andrewcw | last post by:
The split function takes as a parameter what I understand as array of Char. I can define the delimiter like this: string innerText = new string; char chSplit={'='};...
14
by: Ron | last post by:
Hello, I am trying to parse a string on the newline char. I guess vbCrLf is a string constant. How can I parse my string - data - on the newline char? .... data += ASCII.GetString(buffer, 0,...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
7
by: lgbjr | last post by:
Hi All, I'm trying to split a string on every character. The string happens to be a representation of a hex number. So, my regex expression is (). Seems simple, but for some reason, I'm not...
1
by: mdefoor | last post by:
I've written the following sample to split a string into chunks. Is this the right approach or is there perhaps a better way to accomplish getting chunks of a string? #include <stdio.h>...
8
by: Wijaya Edward | last post by:
Hi all, I was trying to split a string that represent chinese characters below: ??? But why the split function here doesn't seem
4
by: mjbauer95 | last post by:
Here is my function to split 2 strings. It has no errors but the function returns an array of lots of random characters. char * split(const char * original, const char * search) { char...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.