473,550 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array to String

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

string[] foo = {"abc","def","g hi"};
string s1 = string.Concat(f oo);
string s2 = string.Join(" ", foo);

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

string[] foo = {"abc","def","g hi"};
string s1 = string.Concat(f oo);
string s2 = string.Join(" ", foo);

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\gh i\";
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.WriteLi ne(s1) - it might actually be

Apr 2 '08 #4
On Apr 2, 11:22 am, Marc Gravell <marc.grav...@g mail.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.WriteLi ne(s1) - it might actually be

i look this when i create a txt file. if i try with console.writeli ne
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("\

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

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1...
by: deko | last post by:
I need to create a basic one-dimensional array of strings, but I don't know how many strings I'm going to have until the code is finished looping. pseudo code: Dim astrMyArray() Do While Not rst.EOF i = i + 1 If rst!Something = Then astrMyArray(i) = rst!Something
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where a * occurs in the string). This split function should allocate a 2D array of chars and put the split results in different rows. The listing below...
by: Zordiac | last post by:
How do I dynamically populate a string array? I hope there is something obvious that I'm missing here Option Strict On dim s() as string dim sTmp as string = "test" dim i as integer s(i)=new string(test) Above line gives - error implicit conversion string to 1-dim array of
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... field1...field2...field3...
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return...
by: Jim Carlock | last post by:
Looking for suggestions on how to handle bad words that might get passed in through $_GET variables. My first thoughts included using str_replace() to strip out such content, but then one ends up looking for characters that wrap around the stripped characters and it ends up as a recursive ordeal that fails to identify a poorly constructed...
by: Peter Hallett | last post by:
I would like to set up a string array as a class member, or field, and then populate this array by reading in from a text file, but I cannot find the appropriate syntax. The getter and setter are very unhappy with the idea and the compiler refuses to play ball with any of the attempts I have made to build such a structure. There is no...
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion....
by: dlite922 | last post by:
difficult to explain, easier to show: Here's what my data looks like on the PHP side: Array ( => Array ( => 20003001 => ABC RESTAURANT
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.