ToObservableCollection
CodeProject
I’ve found myself writing this bit over several times and though to myself. “Self you should put this somewhere.”
And so I answer back….OK. As an added bonus you can use it too.
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
using System.Collections.Generic; using System.Collections.ObjectModel; namespace Example.Extensions { public static class Extensions { public static ObservableCollection ToObservableCollection(this IEnumerable enumerable) { var col = new ObservableCollection(); foreach (var cur in enumerable) { col.Add(cur); } return col; } } } |