public static Coupons.Domain.RejectedCoupons CoupontoRej(Coupons.Domain.Coupon coupon) {
Coupons.Domain.RejectedCoupons a = coupon;
return a;
帮助我,得到错误,
不为我工作
Error 2 Cannot implicitly convert type 'Com.Arpur.Coupons.Domain.Coupon' to 'Com.Arpur.Coupons.Domain.RejectedCoupons' C:\Users\Agha\Desktop\Coupon\Com.Arpur.Coupon.User\Helpers\ExtensionMethods.cs 71 48 Com.Arpur.Coupon.User
答案 0 :(得分:1)
乍一看似乎RejectedCoupons不是Coupons的基类,因此隐式转换不会起作用(除非有一些隐式转换运算符)
为什么不创建新的RejectedCoupons并使用优惠券的属性填充
return new RejectedCoupons {
prop1 = coupon.prop1,
prop2 = coupon.prop2,
...
}