【发布时间】:2021-08-25 08:08:17
【问题描述】:
您可以将表达式传递给另一个构造函数,如下所示:
using System;
public class Wine{
public decimal Price;
public int Year;
public Wine(decimal price){Price = price;}
public Wine(decimal price, int year) : this(price) {Year = year;}
public Wine(decimal price, DateTime year) : this (price, year.Year) {}
}
在书中 - “你调用它的任何方法都可能失败。但是,它可以调用静态方法。
我的问题是“为什么”?
【问题讨论】:
标签: c# methods constructor-overloading