C#中this关键字 - 构造函数重载调用 官网
this关键字还能在构造函数里调用同一个类的其他构造函数,这被称作构造函数重载调用。 public class Rectangle{ public int width; public int height; // 构造函数1 public Rectangle() : this(1, 1) { } // 构造函数2 public Rectangle(int width, int height) { this.width = width; this.height = height; }}// 调用示例class Program{ static void Main() { Rectangle r = new Rectangle(); Console.WriteLine(r.width); // 输出: 1 Console.WriteLine(r.height); // 输出: 1 }} 注意:构造函数重载调用时,this调用必须是构造函数的第一条语句。