Created
April 29, 2015 21:17
-
-
Save Jalalx/c5290ad92f0578f16f33 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace System.Linq | |
{ | |
public static class LinqExtensions | |
{ | |
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> e, Func<T, IEnumerable<T>> f) | |
{ | |
return e.SelectMany(c => f(c).Flatten(f)).Concat(e); | |
} | |
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action) | |
{ | |
foreach (var item in collection) | |
{ | |
action(item); | |
} | |
} | |
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> collection) | |
{ | |
return new ObservableCollection<T>(collection); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment