Search code examples
c#observablecollectioncovariance

How can i cast into a ObservableCollection<object>


How can i cast

from ObservableCollection<TabItem> into ObservableCollection<object>

this doesnt work for me

(ObservableCollection<object>)myTabItemObservableCollection

Solution

  • you should copy like this

    return new ObservableCollection<object>(myTabItemObservableCollection);