为什么以下代码必须使用显式接口实现语法定义“CalcUsable”?(见最后一行代码)如果我使用非显式语法,(即公共十进制 CalcUsable)我会收到“不一致的可访问性”错误,具体来说:
“参数类型 ...List (IVoucher) 比方法 CalcUsable(...) 更难访问”
interface IVoucher
{
string Serial { get; }
decimal FaceValue { get; }
string DiscountType { get; }
string ApplyMsg { get; }
string RejectMsg { get; }
decimal CalcUsable(List<Product> products, List<IVoucher> vouchers);
}
// 'GiftVoucher' models the simple voucher which has no use restrictions.
//
public class GiftVoucher : IVoucher
{
public string Serial { get; private set; }
public decimal FaceValue { get; private set; }
public string DiscountType { get; private set; }
public string ApplyMsg { get; private set; }
public string RejectMsg { get; private set; }
public GiftVoucher(string serial, decimal faceValue)
{
Serial = serial;
FaceValue = faceValue;
ApplyMsg = string.Empty;
RejectMsg = string.Empty;
DiscountType = "Gift";
}
// 'CalcUsable' provides the voucher applicability logic.
//
decimal IVoucher.CalcUsable(List<Product> products, List<IVoucher> vouchers)
{
blar, blar, blar...