Hi,

i am currently making a class to handle xml files but my class will have a lot of child and i dont know if the way i keep the parent in the child node will be a copy of it or a pointer to it....

thx for taking time to answer.

private class XmlSubNode
        {
            List<XmlSubNode> m_lxsnMainList;
            XmlNode m_MainNode;
            XmlSubNode m_xsnParent;
            string m_sName;

            public XmlSubNode(XmlNode xnXmlNode) : this(xnXmlNode,null){}
            public XmlSubNode(XmlNode xnXmlNode,XmlSubNode Parent)
            {
                this.m_MainNode = xnXmlNode;
                this.m_sName = xnXmlNode.Name;
                this.m_xsnParent = Parent;

                if (this.m_MainNode.HasChildNodes)
                {
                    foreach (XmlNode xNode in this.m_MainNode.ChildNodes)
                    {
                        XmlSubNode SubNode = new XmlSubNode(xNode,this);
                        this.m_lxsnMainList.Add(SubNode);
                    }
                }
            }


            public XmlSubNode ParentNode
            {
                get { return this.m_xsnParent; }
            }
            public List<XmlSubNode> ChildNodes
            {
                get { return m_lxsnMainList; }
            }
            public bool HasParent
            {
                get
                {
                    if (this.ParentNode == null) return false;
                    else return true;
                }
            }
            public bool HasChildNodes
            {
                get { return (m_lxsnMainList.Count > 0); }
            }
            public string Name
            {
                get { return m_sName; }
            }
        }
    }

after some little test it seam to be a fail as it only store a copy of the parent... i need to store a reference to the parent.... any idea how i can do this without using pointer or unsafe code ???

EDIT : sorry my test are maybe bad.... so does the code above will have a ref or a copy of it and if it is a copy, how i could store a ref to the parrent.

Edit 2 : solved by my self and a friend on msn, sorry for wasting your time.

thx to all who read this post....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.