找不到合适的方法来覆盖 toString

no suitable method found to override toString

class Persoana
    {
        public string name;
        public Persoana[] children;

        Persoana(string nume, Persoana[] copii) {
            this.name = name;
            this.children = children;
        }

        public override string toString() {   //what is wrong in this function?
            string temp = null;
            for (int i = 0; i < this.children.Length; i++)
                temp = temp + this.children[i].name;    //I don' know how to do it with a string.join in this case
            return string.Format("Parent name: {0}  Number of children: {1}   Children: {2}", name, children.Length);
        }
    }

我认为您需要输入 'String',而不是 'string'。