Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Convert IEnumerable to ObservableCollection

using System.Collections.ObjectModel; public static class Extensions {     public static ObservableCollection<T> AsObservableCollection<T>(this System.Collections.Generic.IEnumerable<T> col)     {         var newcol = new ObservableCollection<T>();         foreach (var item in col)         {             newcol.Add(item);         }         return newcol;     } }