Skip to content

Instantly share code, notes, and snippets.

@AndyA13
Last active Oct 11, 2015
Embed
What would you like to do?
To comma seperated list
private string ToCommaSeperatedString<T>(IEnumerable<T> items, Func<T, string> property)
{
if (items != null && items.Count() > 0)
{
List<string> values = new List<string>();
foreach (T item in items)
{
values.Add(property.Invoke(item));
}
if (values.Count > 0)
{
return String.Join(", ", values);
}
}
return String.Empty;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment