How can i cast
from ObservableCollection<TabItem> into ObservableCollection<object>
this doesnt work for me
(ObservableCollection<object>)myTabItemObservableCollection
you should copy like this
return new ObservableCollection<object>(myTabItemObservableCollection);
Basically, you can't. Not now, and not in .NET 4.0.
What is the context here? What do you need? LINQ has Cast<T>
which can get you the data as a sequence, or there are some tricks with generic methods (i.e. Foo<T>(ObservalbleCollection<T> col)
etc).
Or you can just use the non-generic IList
?
IList untyped = myTypedCollection;
untyped.Add(someRandomObject); // hope it works...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With