IEnumerable To Observable Collection - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

IEnumerable To Observable Collection

Demo Code


using System.Collections.ObjectModel;
using System.Collections.Generic;

public class Main{
        public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> coll)
        {/*from  w  w w . j  ava  2s  . c o  m*/
            var c = new ObservableCollection<T>();
            foreach (var e in coll)
                c.Add(e);
            return c;
        }
}

Related Tutorials