I want to write 1 extension method,it's purpose is convert 1 IEnumerable<T> to 1 ObservableCollection<T>, but i've error :
Error 5 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
Here is my code :
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Data;
namespace BookStore.Helper
{
public static class ExtensionMethods
{
public static ObservableCollection<T> ToObservableCollection(this IEnumerable<T> source)
{
ObservableCollection<T> target = new ObservableCollection<T>();
foreach (T item in source)
target.Add(item);
return target;
}
}
}