String.Join on a List of Objects
In .NET 4, you could just use:
var x = string.Join("|", myList);
.NET 3.5 doesn't have as many overloads for string.Join
though - you need to perform the string conversion and turn it into an array explicitly:
var x = string.Join("|", myList.Select(x => x.ToString()).ToArray());
Compare the overloads available:
- .NET 3.5
- .NET 4
Thank you, Jon Skeet. For a more complex object I use the below:
string.Join("-", item.AssessmentIndexViewPoint.Select(x =>
x.ViewPointItem.Name).ToList())