string.Join and LINQ
August 31, 2024
All the time keep forgetting this, while is pretty simple to create a list of string values separated by any character
string.Join(", ", myCollection.Select(p => p.myProperty));
the full LINQ version with aggregate, despite being less performing for that simple case, can provide a flexible way to handle more complex scenario
myCollection
.Select(p => p.myProperty)
.Aggregate((current, next) => current + ", " + next);