ToObservableCollection
Return observable collection for IList object.
Source
/// <summary>
/// To the observable collection.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value">The value.</param>
/// <returns>ObservableCollection<T>.</returns>
public static ObservableCollection<T> ToObservableCollection<T>(this IList<T> value) where T : class
{
if (value == null)
{
return null;
}
var observableCollection = new ObservableCollection<T>(value);
return observableCollection;
}
Example
var cityList = new List<string> { "NewYork", "London" };
var cityListObsCollection = cityList.ToObservableCollection();