How to convert string array to string in C#

By Emanuele Bartolesi at September 08, 2009 04:56
Filed Under: C#

When you got a string array and you want turn into a string, you have two ways.

This way is useful if you work with every single string before convert.

string[] strings = { "hello", "world", "I", "am", "an", "array" };
string result = "";
foreach(string s in strings) {
result += s + " ";
}


This way is the best for performance and for best code.

string output = string.Join(" ", strings);

 

That's all folks!!! Wink

About me

I will also give you some useful tips, based on the modest wisdom gained during the years that I've worked as a developer and project manager.

Widget

Ohloh profile for Emanuele Bartolesi

 

Wakoopa

Software tracking

 

Software tracking

from Amazon



hacker emblem



Scarica il pdf di Game
Rivista Game di videogiochi
Trucchi videogiochi