Skip to content

Instantly share code, notes, and snippets.

@Crisfole
Created July 2, 2012 20:37
Show Gist options
  • Save Crisfole/3035557 to your computer and use it in GitHub Desktop.
Save Crisfole/3035557 to your computer and use it in GitHub Desktop.
Helpful C# IEnumerable extension methods
public static class AppendExtensions
{
public static IEnumerable<V> Append<V>(this V val, IEnumerable<V> enumerable)
{
yield return val;
foreach (V v in enumerable) yield return v;
}
public static IEnumerable<V> Append<V>(this IEnumerable<V> enumerable, V val)
{
foreach (V v in enumerable) yield return v;
yield return val;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment