It’s very simple.
List<string> stringArr = new List<string>();
foreach (var item in db.IconTags)
{
stringArr.Add(item.Tag);
}
string outPut = string.Join(",", stringArr);
I wish it was possible to say for instance:
string outPut = string.Join(",", db.IconTags.Select(t => t.Tag).ToTArray());
Or maybee
string outPut = string.Join(",", db.IconTags, t => t.Tag);
Isn’t there something cool you can do ? I could make my own method, but i was hoping there was something build in.
In .NET 4 or newer you can write this:
In .NET 3.5 you need to add a call to
ToArray: