471,350 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Array to String

Hi, i have a string array, how can i convert it to a string?
Apr 2 '08 #1
6 1468
For example:

string[] foo = {"abc","def","ghi"};
string s1 = string.Concat(foo);
string s2 = string.Join(" ", foo);

Marc
Apr 2 '08 #2
On Apr 2, 10:44 am, Marc Gravell <marc.grav...@gmail.comwrote:
For example:

string[] foo = {"abc","def","ghi"};
string s1 = string.Concat(foo);
string s2 = string.Join(" ", foo);

Marc
My result is a one string with the "\" separetor....
i use String.Join but the result is :
string s1= "abc\"def\"ghi\"; but it's wrong!
the right result must have s1 = "abc\def\ghi\";
Apr 2 '08 #3
string s1= "abc\"def\"ghi\"; but it's wrong!

Where are you looking at this? The IDE tool-tip displays it with
escape symbols. Try Console.WriteLine(s1) - it might actually be
right.

Marc
Apr 2 '08 #4
On Apr 2, 11:22 am, Marc Gravell <marc.grav...@gmail.comwrote:
string s1= "abc\"def\"ghi\"; but it's wrong!

Where are you looking at this? The IDE tool-tip displays it with
escape symbols. Try Console.WriteLine(s1) - it might actually be
right.

Marc
i look this when i create a txt file. if i try with console.writeline
it's right!
but i must create an output file...
Apr 2 '08 #5
thank's to all! i resolve my problem!
my wrong istruvtion is String s1= string.join("\"",foo) and this
concatenates a backshals and quotes but i must concatenates only a
backslash and the right istruction is String s1 = string.join("\
\",foo).

thaks
bye
Apr 2 '08 #6
my wrong istruvtion is String s1= string.join("\"",foo) and this
concatenates a backshals and quotes
Actually that just concatenates quotes... but glad you are sorted ;-p

If you are doing a lot of this, the alternative syntax might be
clearer:

"\\" is the same as @"\";
Apr 2 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Mike S. Nowostawsky | last post: by
4 posts views Thread by Simon Schaap | last post: by
11 posts views Thread by Zordiac | last post: by
7 posts views Thread by Jim Carlock | last post: by
14 posts views Thread by Peter Hallett | last post: by
reply views Thread by XIAOLAOHU | 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.