Created
July 2, 2012 20:37
-
-
Save Crisfole/3035557 to your computer and use it in GitHub Desktop.
Helpful C# IEnumerable extension methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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