public class Item
{
public string id { get; set;}
public string Color { get; set;}
}
public class Test
{
public ICollection<Item> Items { get; set; }
public void ConCat
{
string a = ?
}
}
我有上面的类结构,我想使用 LINQ 连接该搭配内所有项目的颜色。知道怎么做吗?
最佳答案
尝试:
string a = string.Join(";", Items.Select(item => item.Color));
关于c# - 连接集合中对象的属性。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33061547/