Skip to content

Instantly share code, notes, and snippets.

@kibotu
Created December 18, 2014 15:56
Show Gist options
  • Save kibotu/a5e97b23fc5a0868baa1 to your computer and use it in GitHub Desktop.
Save kibotu/a5e97b23fc5a0868baa1 to your computer and use it in GitHub Desktop.
IEnumerable ToString with separator extension method
public static string ToString<T>(this IEnumerable<T> list, string separator)
{
StringBuilder sb = new StringBuilder();
foreach (var obj in list) {
if (sb.Length > 0) {
sb.Append(separator);
}
sb.Append(obj);
}
return sb.ToString();
}
Debug.Log(list.ToString( ", "));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment