Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Observable Collection demo

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections.ObjectModel; public static class Collections {     public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> enumerableList)     {         if (enumerableList != null)         {             //create an emtpy observable collection object             var observableCollection = new ObservableCollection<T>();             //loop through all the records and add to observable collection object             foreach (var item in enumerableList)                 observableCollection.Add(item);             //return the populated observable collection             return observableCollection;         }         return null;     } }