Custom class for data arranged in tree fashion
<p>I'm trying to make a custom class that arrange data in the following fashion:-</p>

<pre><code>Departments 
        Section 1
                 Person 1
                 Person 2
        Section 2
        ... etc
</code></pre>

<p>Below is the code i wrote but it is not working as i'm thinking:-</p>

<pre><code>    public class Sections
    {
        private List&lt;Section&gt; _Section = new List&lt;Section&gt;();
        public List&lt;Section&gt; Section
        {
            get
            {
                return this._Section;
            }
        }
    }
    //Innehåller alla detailer om varje sektion
    public class Section
    {
        public string Name { get; set; }
        public int Capacity { get; set; }
        public int MinimumStaffing { get; set; }
        public int IdealStaffing { get; set; }

        private List&lt;Person&gt; _Employee = new List&lt;Person&gt;();
        public List&lt;Person&gt; Employee
        {
            get
            {
                return this._Employee;
            }
            set { }
        }
    }
    //Innehåller alla info. om en enskild personal
    public class Person
    {
        public string Name { get; set; }
        public string Email { get; set; }
        public int TelephoneNo { get; set; }
        public int Pager { get; set; }
        public int HomePhone { get; set; }
        public string Title { get; set; }
    }
</code></pre>

<p>What i'm trying to do is:-
First:- get the name of Section 1 and save it to a string.
Second:- get the name of each person in this section (Section 1).
Third:- add both the name of Section 1 and the list of persons in this section to the list Named Departments.</p>

<p>Below is the code that i'm using to achieve what i'm trying to do (Which is not working for me, see below for more info)</p>

<pre><code>if (index == 0 || index == node.ChildNodes.Count)
                        {
                            if (node.ChildNodes.Count == 2)
                            {
                                sektionsNamn = node.ChildNodes[0].InnerText;
                                continue;
                            }
                            else if (node.ChildNodes.Count &gt; 2)
                            {
                                Sektion.Employee.Add(new Person() { Name = node.ChildNodes[0].InnerText });
                                index = node.ChildNodes.Count;
                                continue;
                            }
                        }
                        else
                        {
                            Sektioner.Section.Add(new Section() { Name = sektionsNamn, Employee=Sektion.Employee });
                            index = 0;
                        }
</code></pre>

<p>the problem is with the else statment, it returns 0 counts, i.e it adds the Name property, but it doesn't add the employee list.</p>

<p>Any idea how to overcome this?? </p>

<p>Sorry for bothering and thanks in advance.</p>
