Declare a list.
List < string > l = new List < string > ();
Now, add the elements to the list.
// elements l.Add("Accessories"); l.Add("Footwear"); l.Add("Watches");
Now convert it to string.
string str = string.Join(" ", l.ToArray());
Let’s see the final code in C# to convert list to string -
using System; using System.Collections.Generic; class Demo { static void Main() { List < string > l = new List < string > (); // elements l.Add("Accessories"); l.Add("Footwear"); l.Add("Watches"); string str = string.Join(" ", l.ToArray()); Console.WriteLine(str); } }
The above is the detailed content of How to convert list to string in C#?. For more information, please follow other related articles on the PHP Chinese website!