|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Implementing an interface by relying on base classI'd like to do be able to implement an interface in a derived class by relying on the base class for some of the members. For example like this: Interface ITest Property prpA() As Integer Property prpB() As Integer End Interface Public MustInherit Class BaseClass Public Property prpA() As Integer Get Return 1 End Get Set(ByVal Value As Integer) End Set End Property End Class Public Class DerivedClass Inherits BaseClass Implements ITest Public Property prpB() As Integer Implements ITest.prpB Get Return 0 End Get Set(ByVal Value As Integer) End Set End Property End Class But the compiler doesn't recognise prpA as being present in DerivedClass. Can anyone tell me how I could get round this, and also why it should be that this is not allowed? Thanks, Gareth Maybe you could use C# as the problem does not exist there
interface IPoint { // Property signatures: int x { get; set; } int y { get; set; } } class BasePoint { private int myX; // Property implementation: public int x { get { return myX; } set { myX = value; } } } class MyPoint : BasePoint, IPoint { // Fields: private int myY; // Constructor: public MyPoint(int x, int y) { x = x; myY = y; } public int y { get { return myY; } set { myY = value; } } } Show quoteHide quote "Gareth" wrote: > Hi, > > I'd like to do be able to implement an interface in a derived class by > relying on the base class for some of the members. For example like > this: > > Interface ITest > Property prpA() As Integer > Property prpB() As Integer > End Interface > > Public MustInherit Class BaseClass > Public Property prpA() As Integer > Get > Return 1 > End Get > Set(ByVal Value As Integer) > > End Set > End Property > End Class > > Public Class DerivedClass > Inherits BaseClass > Implements ITest > > Public Property prpB() As Integer Implements ITest.prpB > Get > Return 0 > End Get > Set(ByVal Value As Integer) > > End Set > End Property > End Class > > But the compiler doesn't recognise prpA as being present in > DerivedClass. Can anyone tell me how I could get round this, and also > why it should be that this is not allowed? > > Thanks, > > Gareth > >
A challenge to all MVP's.......GET A J.O.B. for once in your life
Windows service Unable to access mapped drives on XP and 2003 Boxe Strange Excel importing problem How to do simple memcpy in C#? Text Files, Encoding and NewLine character Read File Fast Simple architecture question. Enable a windows form over another one? HOW TO CONNECT TO SQL SERVER 2000 DATABASE Send mail in BOTH html and text formats |
|||||||||||||||||||||||