Skip to content

Instantly share code, notes, and snippets.

@AndyA13
Last active October 11, 2015 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyA13/3859427 to your computer and use it in GitHub Desktop.
Save AndyA13/3859427 to your computer and use it in GitHub Desktop.
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