日期:2014-05-17 浏览次数:20943 次
void Test()
{
H b = new H(int.MinValue,
new H(1,
new H(2,
new H(3),
new H(4,
new H(5)
)
)
)
);
int v = b[0][0][1][0]; // v== 5;
}
class H
{
List<H> children = new List<H>();
public H(int value, params H[] children)
{
this.Value = value;
this.children.AddRange(children);
}
public H this[int index] //<--
{
get { return children[index]; }
}
public int Value
{
get; set;
}
public int Add(H h)
{
children.Add(h);
return children.Count - 1;
}
public static implicit operator int(H h)
{
return h.Value;
}
}