递归类C#

Joh*_*ohn 1 c# oop recursion class

我可以像这样定义构造函数吗?附加问题:我可以在构造函数中调用类的构造函数吗?

class SubArray
{
    List<int> array;
    string parent;
    string name;
    SubArray child;

    public SubArray(SubArray child, string name)
    {
        this.child = child;
        List<int> array = new List<int>();
        this.name = name;
    }
}
Run Code Online (Sandbox Code Playgroud)

Ale*_*tof 11

没有限制,但像任何递归一样 - 它需要一个停止条件.否则会导致堆栈溢出(PUN打算:)).

  • 在那里双关语的额外荣誉.:) (3认同)