Search Results

Search found 1 results on 1 pages for 'millicent'.

Page 1/1 | 1 

  • [C#] How do I make hierarchy of objects from two alternating classes?

    - by Millicent
    Here's the scenario: I have two classes ("Page" and "Field"), that are descended from a common class ("Pield"). They represent tags in an XML file and are in the following hierarchy: <page> <field> <page> ... </page> ... </field> ... </page> I.e.: Page and Field objects are in a hierarchy of alternating type (there may be more than one Page or Field to each rung of the hierarchy). Every Field and Page object has a parent property, which points to the respective parent object of the other type. This is not a problem unless the parent-child mechanism is controlled by the base class (Pield), which is shared by the two descended classes (Page and Field). Here is one try, that fails at the line "Pield child = new Pield(pchild, this);": class Pield<T> { private T _pield_parent; ... private void get_children() { ... Pield<Page> child = new Pield<Page>(pchild, this); ... } ... } class Page : Pield<Field> { ... } class Field : Pield<Page> { ... } Any ideas about how to solve this elegantly? Best, Millicent

    Read the article

1