A couple months ago, I had written some posts on converting String and Char Arrays
Convert a String Array to a Decimal Array using C# or VB.NET
Convert Char Array to String and Vice Versa
Here’s a very simple way if you want to convert a String Array to String using C# LINQ
static void Main(string[] args)
{
string[] indiaCityVisit = {
"Delhi", "Jodhpur", "Mumbai", "Pune", "Agra",
"Shimla", "Bengaluru", "Mysore", "Ooty",
"Jaipur", "Nagpur", "Amritsar", "Hyderabad",
"Goa", "Ahmedabad" };
string cities = String.Join(",", indiaCityVisit
.Select(s => s.ToString())
.ToArray());
Console.WriteLine(cities);
Console.ReadLine();
}
The LINQ query doesn't do anything here. All the work is done by String.Join.
ReplyDeletestring cities = String.Join(",", indiaCityVisit);
ReplyDelete