list属性字段直接转成字符串数组List<Car> cars = //whatever;
string concat = String.Join(",", cars.Select(c => c.Name).ToArray());
数组类型字符串转数组string concat = cars.Select(c => c.Name).Aggregate(new StringBuilder(), (sb, current) =>
{
return sb.Length == 0 ? sb.Append(current) : sb.AppendFormat(",{0}", current);
}).ToString();
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论