R
ryanbreakspear
Hi all,
I have the classes BaseObject, and BaseList<T> to use as base classes
for some business objects.
I descend from both of these: DescendantObject: BaseObject and
DescendantList: BaseList<DescendantObject>.
How can I cast from a BaseList<BaseObject> to a DescendantList? Or
even a BaseList<BaseObject> to a BaseList<DescendantObject>?
I have put in a derivation constraint on the BaseList<T> so the
declaration looks like:
public class BaseList<T>: BindingList<T> where T: BaseObject
I would have thought that is enough to tell the compiler that it is
safe to perform the casts above.
Thanks in advance!
I have the classes BaseObject, and BaseList<T> to use as base classes
for some business objects.
I descend from both of these: DescendantObject: BaseObject and
DescendantList: BaseList<DescendantObject>.
How can I cast from a BaseList<BaseObject> to a DescendantList? Or
even a BaseList<BaseObject> to a BaseList<DescendantObject>?
I have put in a derivation constraint on the BaseList<T> so the
declaration looks like:
public class BaseList<T>: BindingList<T> where T: BaseObject
I would have thought that is enough to tell the compiler that it is
safe to perform the casts above.
Thanks in advance!