to know about a function is exists

  • Thread starter Thread starter jainshasha
  • Start date Start date
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...
 
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
 
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(',');
 
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
 
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.
 
Back
Top