I was wondering if anyone can tell me if this behavior is possible in C # 4.0
I have a hierarchy of objects that I would like to keep strictly typed. Something like that
class ItemBase {}
class ItemType<T> where T : ItemBase
{
T Base { get; set; }
}
class EquipmentBase : ItemBase {}
class EquipmentType : ItemType<EquipmentBase> {}
What I want to do something like this
ItemType item = new EquipmentType();
And I want item.Base to return an ItemBase type. Basically, I want to know if it is smart enough to strongly typify a base class without strong typing. The advantage of this is that I can simply return ItemType back to EquipmentType and get all the strict typing back.
Maybe I'm thinking about it all wrong ...
source
share