ประกาศ List และเพิ่มข้อมูล:
List<string> l = new List<string>();
l.Add("Accessories");
l.Add("Footwear");
l.Add("Watches");
แปลงเป็น String ด้วย string.Join:
string str = string.Join(" ", l.ToArray());
ตัวอย่าง
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
List<string> l = new List<string>();
l.Add("Accessories");
l.Add("Footwear");
l.Add("Watches");
string str = string.Join(" ", l.ToArray());
Console.WriteLine(str);
}
}