This question is a follow-up to my last question with a reference to COM Interop.
Let's say I have the following 2 interfaces and implementing classes:
public interface ISkuItem
{
public string SKU { get; set; }
}
public interface ICartItem : ISkuItem
{
public int Quantity { get; set; }
public bool IsDiscountable { get; set; }
}
public class CartItem : ICartItem
{
//implemented properties...
}
Or, in VB.NET:
Public Interface ISkuItem
Property SKU() As String
End Interface
Public Interface ICartItem
Inherits ISkuItem
Property Quantity() As Integer
Property IsDiscountable() As Boolean
End Interface
Public Class CartItem
Implements ICartItem
'Implemented Properties'
End Class
Interfaces are important in COM interop for exposing properties and methods to IntelliSense in the VB6 IDE (per this article). However, because ICartItem
is inherited from ISkuItem
, SKU
is not explicitly defined in ICartItem
and thus is not visible in IntelliSense in VB6 and even throws a compiler error when trying to write to objCartItem.SKU
.
I've tried using Shadows
and Overloads
on the SKU
property in ISkuItem
, but then the compiler wants me to explicitly implement SKU
for both ISkuItem
and ICartItem
within the CartItem
class. I don't think that's what I want.
Is there a way (in either VB.NET or C#) to explicitly declare the SKU
property in ICartItem
without having to declare SKU
twice in the CartItem
class?