In the Keltex answer, you can omit the call to the ToArray() method, since the String.Join method works with any IEnumerable<T> .
The hint for a more concise and customizable form is to override the ToString() method of the collection element class, in your case this can be done as:
public class Service_lineToSubcontract { public Service_line service_line {get; set;} ... public override string ToString() { return service_line.service_line_name;
and then use a more concise form:
<%= Html.Encode(String.Join(", ", item.Service_lineToSubcontracts)) %>
this hint may not be the best choice in this context, but it simplifies a lot when you have collections of key-value pairs or you need a comma-separated list of descriptions made up of more than one property
source share