C#中构造函数的有关问题
C#中构造函数的问题
在一个产品类中有两个构造方法,红色那个构造方法我不懂是啥意思,请教下各位,多谢
------解决方案--------------------
构造函数是可以重载的,你看下红色的没有“ID” 这个参数,而方法体里面
- C# code
[color=#FF0000]public Product(String name,Decimal price,String description) :this(0,name,price,description);[/color] public Product(int id,String name,Decimal price,String description) { _id=id; _name=name; _price=price; _description=description; }
在一个产品类中有两个构造方法,红色那个构造方法我不懂是啥意思,请教下各位,多谢
------解决方案--------------------
构造函数是可以重载的,你看下红色的没有“ID” 这个参数,而方法体里面
- C# code
:this(0,name,price,description);