다음 코드는 명시 적 인터페이스 구현 구문을 사용하여 'CalcUsable'을 정의해야합니까? (코드의 마지막 줄을보십시오) 명시 적이지 않은 구문 (예 : public decimal CalcUsable)을 사용하는 경우, 구체적으로 다음과 같은 "일관성없는 액세스 가능성"오류가 발생합니다.명시 적 인터페이스 구현이 필요하지만 하나의 인터페이스 만 사용 중입니까?
"매개 변수 유형 ... 목록 인터페이스 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...
공개 인터페이스로 설정해보세요 – JRLambert
고맙습니다. 그런데 왜 ??? – CodeCabbie