to know about a function is exists

J

jainshasha

hello

I have a long string like this
(0334239,CDEABABCDEEDCBAA#EEBCBD##,##CDB#BCD#B###D#BC#EA#BB#,###B#ACCD#BC#############,
049226,)
now i want the strings to be store in an array that are currently
separated by commas(,)
like this
0334239
CDEABABCDEEDCBAA#EEBCBD##
##CDB#BCD#B###D#BC#EA#BB#
###B#ACCD#BC#############
049226


is there any function available in C# or how can i do this

please help in anyone knows about this...
 
J

Jason Newell

string s =
"(0334239,CDEABABCDEEDCBAA#EEBCBD##,##CDB#BCD#B###D#BC#EA#BB#,###B#ACCD#BC#############,049226,)";
string[] tokens = s.Split(new char[] { ',' });

Jason Newell
www.jasonnewell.net
 
J

Jeff Gaines

hello

I have a long string like this
(0334239,CDEABABCDEEDCBAA#EEBCBD##,##CDB#BCD#B###D#BC#EA#BB#,###B#ACCD#BC#############,
049226,)
now i want the strings to be store in an array that are currently
separated by commas(,)
like this
0334239
CDEABABCDEEDCBAA#EEBCBD##
##CDB#BCD#B###D#BC#EA#BB#
###B#ACCD#BC#############
049226


is there any function available in C# or how can i do this

please help in anyone knows about this...

string[] myArray = longCSVString.Split(',');
 
F

Family Tree Mike

jainshasha said:
hello

I have a long string like this
(0334239,CDEABABCDEEDCBAA#EEBCBD##,##CDB#BCD#B###D#BC#EA#BB#,###B#ACCD#BC#############,
049226,)
now i want the strings to be store in an array that are currently
separated by commas(,)
like this
0334239
CDEABABCDEEDCBAA#EEBCBD##
##CDB#BCD#B###D#BC#EA#BB#
###B#ACCD#BC#############
049226


is there any function available in C# or how can i do this

please help in anyone knows about this...
.

Use string.Split().

Mike
 
J

Jeff Johnson

I have a long string like this
(0334239,CDEABABCDEEDCBAA#EEBCBD##,##CDB#BCD#B###D#BC#EA#BB#,###B#ACCD#BC#############,
049226,)
now i want the strings to be store in an array that are currently
separated by commas(,)
like this
0334239
CDEABABCDEEDCBAA#EEBCBD##
##CDB#BCD#B###D#BC#EA#BB#
###B#ACCD#BC#############
049226


is there any function available in C# or how can i do this

please help in anyone knows about this...

Please note that the answers you have received suggesting the use of
string.Split() work perfectly fine in this case, but may not always. For an
extremely simple CSV format like you posted above, string.Split() is fine.
If your source string contains embedded commas, however, you'll need a more
robust solution.
 

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