Translate

Donnerstag, 31. August 2017

C# IEnumerable to ObservableCollection as extension method

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBLayer.Extensions
{
    public static class IEnumerableExtensions
    {
        public static ObservableCollection<T> ToCollection<T>(this IEnumerable<T> list)
        {
            var collection = new ObservableCollection<T>();
            foreach (var item in list)
                collection.Add(item);
            return collection;
        }
    }
}

Keine Kommentare:

Kommentar veröffentlichen