Possible Duplicate:
LINQ to append to a StringBuilder from a String[]
放弃我的职能性方案,但甚至有可能利用灯巴功能,在阵列中将每一条扼杀都传给一个斯特林物体?
有可能修改这一法典:
// string[] errors = ...
StringBuilder sb = new StringBuilder("<ul>");
foreach (var error in errors)
{
sb.AppendFormat("<li>{0}</li>", error);
}
sb.AppendLine("</ul");
return sb.ToString();
类似情况:
// string[] errors = ...
StringBuilder sb = new StringBuilder("<ul>");
//I know this isn t right, I don t care about a return value
errors.All(s => sb.AppendFormat("<li>{0}</li>", s));
sb.AppendLine("</ul");
return sb.ToString();
感谢任何音响!