Here's what I'm trying to understand; how can you store a generic collection
in a variable/field?
If I have an abstract generic collection class as follows...
public abstract class BizCollection<T > : Collection<T> where T : BizBase
{
// Collection Implementation
override void InsertItem(int index, T item)
{
item.SetParent< BizCollection<T >>(this);
base.InsertItem (index, item);
}
}
And then I have an abstract base business object which has method exposed
which allows you to set the parent collection it belongs to as this...
public abstract class BizBase
{
private BizCollection<T > parent;
public void SetParent(BizCo llection<T> parent)
{
this.parent = parent;
}
}
You’ll notice the logic is that when an Insert is performed on the
collection it tries to call the BizBase objects SetParent() method – but
obviously the code above won’t compile, as you can't declare "private
BizCollection<T > parent" - so if I don't know what the Type is going to be -
how can I store the collection in a field?
Hope that makes sense,
Thanks in advance!