Hi, i have a string array, how can i convert it to a string?
Array to String
Collapse
This topic is closed.
X
X
-
PieroTags: None -
Marc Gravell
Re: Array to String
For example:
string[] foo = {"abc","def","g hi"};
string s1 = string.Concat(f oo);
string s2 = string.Join(" ", foo);
Marc
-
Piero
Re: Array to String
On Apr 2, 10:44 am, Marc Gravell <marc.grav...@g mail.comwrote:My result is a one string with the "\" separetor....For example:
>
string[] foo = {"abc","def","g hi"};
string s1 = string.Concat(f oo);
string s2 = string.Join(" ", foo);
>
Marc
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\gh i\";
Comment
-
Marc Gravell
Re: Array to String
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.WriteLi ne(s1) - it might actually be
right.
Marc
Comment
-
Piero
Re: Array to String
On Apr 2, 11:22 am, Marc Gravell <marc.grav...@g mail.comwrote:i look this when i create a txt file. if i try with console.writeli ne>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.WriteLi ne(s1) - it might actually be
right.
>
Marc
it's right!
but i must create an output file...
Comment
-
Piero
Re: Array to String
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
Comment
-
Marc Gravell
Re: Array to String
my wrong istruvtion is String s1= string.join("\" ",foo) and thisActually that just concatenates quotes... but glad you are sorted ;-pconcatenates a backshals and quotes
If you are doing a lot of this, the alternative syntax might be
clearer:
"\\" is the same as @"\";
Comment
Comment