0
   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
4

1 回答 1

1

乍一看,RejectedCoupons 似乎不是 Coupons 的基类,因此隐式转换不起作用(除非有一些隐式转换运算符)

为什么不创建一个新的 RejectedCoupons 并用优惠券的属性填充它

return new RejectedCoupons {
    prop1 = coupon.prop1,
    prop2 = coupon.prop2,
    ...
}
于 2012-10-09T09:50:42.463 回答