c#中 这种构造方法Recer(…):this(…){ }

class Program
{
static void Main(string[] args)
{
Person p2 = new Person("Carll",10);
Console.ReadKey();
}
}
class Person
{
public Person()
{
Console.WriteLine("P()");
}
public Person(string name)
: this()
{
Console.WriteLine("P(name)");
}
public Person(string name, int age)
: this(name)
{
Console.WriteLine("P(name, age)");
}
}
输出结果:

浙公网安备 33010602011771号