我有一个字典Dictionary<int, Foo> fooDic
,因为它的值是一个类并且Foo
有一个属性_barName
我需要所有名称fooDic
作为 CSV 字符串...例如..
var fooDic = new Dictionary<int, Foo>()
{
{ 0, new Foo { _barId = 10, _barName = "some value" } },
{ 1, new Foo { _barId = 15, _barName = "some Foo value" } },
{ 2, new Foo { _barId = 25, _barName = "some Foobar value" } }
};
我需要输出为
string result = "some value, some Foo value, some Foobar value";
请分享您的想法/解决方案,如何实现?