问题
Poco items are wrapped.
abstract class AbstractPocoUI<T> {
protected T PocoItem;
}
class PocoA {
}
class PocoAUI:AbstractPocoUI<PocoA> {
}
I want to do something like this
var c = new ObservableCollection<PocoAUI>(collectionOfTypePocoA.Cast<PocoAUI>());
How can i override cast operator in abstract class?
What should i do in AbstractPocoUI
to get for example PocoAUI
with PocoA
in PocoItem
field ?
Thanks.
回答1:
You can implement IConvertible
interface or create a TypeConverter
but casting cannot be overriden.
Have a look at Implicit Operator overloading here.
来源:https://stackoverflow.com/questions/5990663/abstract-class-cast-operator