在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
public class Class1
{ string name; public Class1(string name) { this.name = name; Console.WriteLine("1."); Console.WriteLine("parent constracter:"+name); } } public class Class2:Class1 { string age; public Class2() : base("sucre") { Console.WriteLine("2."); } } public class Class3:Class2 { public Class3() : base() { Console.WriteLine("3"); } } class Program { static void Main(string[] args) { Console.WriteLine("实例化1 ++++"); Class1 a = new Class1("kk"); Console.WriteLine("实例化2 ++++"); Class2 b = new Class2(); Console.WriteLine("实例化3 ++++"); Class3 c = new Class3(); } } Console: 实例化1 ++++ 1. parent constracter:kk 实例化2 ++++ 1. parent constracter:sucre 2. 实例化3 ++++ 1.
base: 调用父类构造方法.
parent constracter:sucre 2. 3 请按任意键继续. . . |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论