Mar*_*der 11 c# observablecollection covariance
我怎么能投
from ObservableCollection<TabItem> into ObservableCollection<object>
这对我不起作用
(ObservableCollection<object>)myTabItemObservableCollection
Ars*_*yan 12
你应该像这样复制
return new ObservableCollection<object>(myTabItemObservableCollection);
Mar*_*ell 12
基本上,你不能.不是现在,而不是在.NET 4.0中.
这里的背景是什么?你需要什么?LINQ Cast<T>可以将数据作为   序列获取,或者有一些通用方法的技巧(即Foo<T>(ObservalbleCollection<T> col)等).
或者你可以只使用非泛型IList?
IList untyped = myTypedCollection;
untyped.Add(someRandomObject); // hope it works...