Possible Duplicate:
LINQ to append to a StringBuilder from a String[]
Forgive my functional programming noobiness, but is it even possible to use a lamba function to append each string in an array to a StringBuilder object?
Is it possible to turn this code:
// string[] errors = ...
StringBuilder sb = new StringBuilder("<ul>");
foreach (var error in errors)
{
sb.AppendFormat("<li>{0}</li>", error);
}
sb.AppendLine("</ul");
return sb.ToString();
Into something like this:
// 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();
Thanks for any edification!