How to convert IEnumerable
to ObservableCollection
?
If you're working with non-generic IEnumerable
you can do it this way:
public ObservableCollection
If you're working with generic IEnumerable
you can do it this way:
public ObservableCollection Convert(IEnumerable original)
{
return new ObservableCollection(original);
}
If you're working with non-generic IEnumerable
but know the type of elements, you can do it this way:
public ObservableCollection Convert(IEnumerable original)
{
return new ObservableCollection(original.Cast());
}