Skip to content

Instantly share code, notes, and snippets.

@Jalalx
Created April 29, 2015 21:17
Show Gist options
  • Save Jalalx/c5290ad92f0578f16f33 to your computer and use it in GitHub Desktop.
Save Jalalx/c5290ad92f0578f16f33 to your computer and use it in GitHub Desktop.
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