"wojtas" <wo******@gmail.coma écrit dans le message de news:
11*********************@l39g2000cwd.googlegroups.c om...
| I'm trying to create application with as much as possible methods
| derived from base class. I use two base classes "Document" and
| "DocumentItem", each document has collection of documentItems. When I
| cast object of Document class on one of its subclasses collection of
| documentItems collection remains in base class. I already know that I
| cannot do it with generic collections. Can anybody help me with this,
| or point in right direction?
Without any code as example, it is difficult to see what your problem is.
However, why would you say generics doesn't help ?
class DocumentItem
{
}
class DocumentItemCollection<T: List<Twhere T : DocumentItem { }
class Word : DocumentItem
{
}
class Paragraph : DocumentItem
{
private DocumentItemCollection<Wordwords = new
DocumentItemCollection<Word>();
public DocumentItemCollection<WordWords
{
get { return words; }
}
}
class Document : DocumentItem
{
private DocumentItemCollection<Paragraphparagraphs = new
DocumentItemCollection<Paragraph>();
public DocumentItemCollection<ParagraphParagraphs
{
get { return paragraphs; }
}
private DocumentItemCollection<Documentdocuments = new
DocumentItemCollection<Document>();
public DocumentItemCollection<DocumentDocuments
{
get { return documents; }
}
}
Or am I missing something ?
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer