top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Convert a List to ObservableCollection in C#?

+2 votes
527 views

I had an doubt regarding list to ObservableCollection in C#???

posted Oct 29, 2014 by Puhal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
    public static class ObservableExtensions
       {
      public static ObservableCollection<T> ToObservableCollection<T>(this List<T> items)
       {
        ObservableCollection<T> collection = new ObservableCollection<T>();

        foreach (var item in items)
        {
            collection.Add(item);
        }

        return collection;
        }
       }
answer Oct 30, 2014 by Jdk
...