Tim Van Wassenhove

Passionate geek, interested in Technology. Proud father of two

06 Nov 2009

Couple of methods missing on ObservableCollection

Here are a couple of methods that are missing on ObservableCollection

public static class ObservableCollectionExtensions
{
	public static void AddRange<T>(this ObservableCollection<T> observableCollection, IEnumerable<T> elements)
	{
		foreach (var element in elements) observableCollection.Add(element);
	}

	public static ObservableCollection<T> Create<T>(IEnumerable<T> elements)
	{
		var observableCollection = new ObservableCollection<T>();
		observableCollection.AddRange(elements);
		return observableCollection;
	}
}