Nested set of class definitions and reference examples

        When developing applications sometimes need to define a simple type, sometimes need to define a set of complex type, complex type may be set to a simple object storage class, it may also be used to store other types of collections. This time it uses nested set of class definitions and references. The following sample code.

ListBase class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListEmbeddedTest
{
    public class ListBase
    {
        //int number;
        public MyList parentList;

    }
}
MyList class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Collections;

namespace ListEmbeddedTest
{
    public class MyList : ListBase
    {
        public ArrayList m_children = new ArrayList();
    }
}
World class: 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListEmbeddedTest
{
    public class World : ListBase
    {
        public double  radius;
        public string name;
        
    }
}
PathPoint categories:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListEmbeddedTest
{
    public class PathPoint : ListBase
    {
        public int pointCount;
    }
}
PathList categories:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListEmbeddedTest
{
    public class PathList : MyList
    {
        public int totalNum;
    }
}
Consumer categories:
the using the System;
 the using the System.Collections.Generic;
 the using the System.Linq;
 the using the System.Text; 

namespace ListEmbeddedTest 
{ 
    // consumers: all classes defined in the project using 
    public  class Consumer 
    { 
        public  String consumerName;
         public of MyList renderableObjectsList = new new of MyList ( ); 
    } 
}
Program categories:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListEmbeddedTest
{
    class Program
    {
        static void Main(string[] args)
        {
            PathPoint pathPoint=new PathPoint();
            pathPoint.pointCount=4;

            PathPoint pathPoint1 = new PathPoint();
            pathPoint1.pointCount = 3;

            PathList pathList = new PathList();
            pathList.totalNum = 7;
            pathList.m_children.Add(pathPoint);
            pathList.m_children.Add(pathPoint1);

            pathPoint.parentList = pathList;
            pathPoint1.parentList = pathList;

            World world = new World();
            world.radius = 6378137;
            world.name = "Earth";

            Consumer consumer = new Consumer();
            consumer.consumerName = "主应用程序";
            consumer.renderableObjectsList.m_children.Add(pathList);
            consumer.renderableObjectsList.m_children.Add(world);

            System.Console.WriteLine("Hello");
        }
    }
}

A detailed analysis is not to say, we run the source code understand it.

Download Source: Source

Guess you like

Origin www.cnblogs.com/rainbow70626/p/11852363.html