先有鸡还是先有蛋?

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

namespace ChickenAndEgg
{
    class Program
    {
        static void Main(string[] args)
        {
            Egg e = new Egg();
            Console.WriteLine("ID:"+e.ID.ToString());
            Chicken c = e.BecomeChicken();
            Console.WriteLine("ID:" + c.ID.ToString());
            e = c.ProductEgg();
            Console.WriteLine("ID:" + e.ID.ToString());
            Console.ReadKey();
        }

       
    }

    class Chicken
    {
        public Guid ID;

        public Chicken()
        {
            ID = Guid.NewGuid();
        }
        public Egg ProductEgg()
        {
            Egg e = new Egg();
            e.ID = Guid.NewGuid();
            return e;
        }
    }

    class Egg
    {
        public Guid ID;
        public Egg()
        {
            ID = Guid.NewGuid();
        }
        public Chicken BecomeChicken()
        {
            Chicken c = new Chicken();
            return c;
        }
    }
}

posted @ 2008-12-19 17:22  昕友软件开发  阅读(218)  评论(0编辑  收藏  举报
欢迎访问我的开源项目:xyIM企业即时通讯