Skip to content

Instantly share code, notes, and snippets.

@huobazi
Created April 18, 2012 05:01
Show Gist options
  • Save huobazi/2411195 to your computer and use it in GitHub Desktop.
Save huobazi/2411195 to your computer and use it in GitHub Desktop.
IEnumableExtensions
public static class IEnumableExtensions
{
public static void ForEach<T>(this IEnumerable<T> value, Action<T> action)
{
foreach (var v in value)
{
action(v);
}
}
public static string Join<T>(this IEnumerable<T> collection, string separator)
{
if (!collection.Any())
{
return string.Empty;
}
StringBuilder sb = new StringBuilder();
collection.ForEach(e => sb.Append(e.ToString() + separator));
return sb.ToString().Substring(0, sb.Length - separator.Length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment