先有鸡还是先有蛋?
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;
}
}
}
目前维护的开源产品:https://gitee.com/475660