|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Implementing an interface?and I have come across an odd problem implementing an interface. The interface is a custom interface, IDrillDown, which declares one read-only property with the following VB.NET signature: Public ReadOnly Property ActiveText() As String I have declared the interface in the class declaration, like this: Public Class CustomerItem Implements IDrillDown ... End Class Later in the class, I implement the interface by by declaring my ActiveText property: Public ReadOnly Property ActiveText() As String Get Return Me.Name End Get End Property VB.NET is giving me a compile-time error, saying that the class must implement the ActiveText property for the IDrillDown interface. Needless to say, I am puzzled, since I have implemented the property with the signature required by the interface. Can anyone shed some light on this? Thanks. -- David Veeneman Foresight Systems David Veeneman domain is my last name wrote:
Show quoteHide quote > I'm new to VB.NET, and I am translating an object model from C# to VB.NET, Public ReadOnly Property ActiveText() As String Implements> and I have come across an odd problem implementing an interface. > > The interface is a custom interface, IDrillDown, which declares one > read-only property with the following VB.NET signature: > > Public ReadOnly Property ActiveText() As String > > I have declared the interface in the class declaration, like this: > > Public Class CustomerItem > Implements IDrillDown > > ... > > End Class > > Later in the class, I implement the interface by by declaring my ActiveText > property: > > Public ReadOnly Property ActiveText() As String > Get > Return Me.Name > End Get > End Property > > David - IDrillDown.ActiveText Get Return Me.Name End Get End Property HTH, -- Tom Shelton David Veeneman wrote:
> The interface is a custom interface, IDrillDown You have created a method that can implement th Interface's property, > Public ReadOnly Property ActiveText() As String > Public ReadOnly Property ActiveText() As String > Get > Return Me.Name > End Get > End Property > > VB.NET is giving me a compile-time error, saying that the class must > implement the ActiveText property for the IDrillDown interface. but you haven't told VB to connect to two. Interface implementations are explicit, so you have to add the "Implements [Interfacename].[MethodName]" clause. It allows you to do funny things like this : Private ReadOnly Property Message() As String _ Implements I.ActiveText Yes, that's a Private property, implementing a Public Interface property with a totally /different/ name (but /same/ signature, otherwise). HTH, Phill W.
VB Express SQL Express Remote Connection
Trouble with "Process's" please help! .NET equivilant of isnumeric copy HTML information Datagridview Search? Text missing from RadioButtons in Groupbox Merging Datasets Incorrect behavior of IIf in VB.NET (.NET Framework 1.1 SP1) Printing in VB.Net can I use Imports with a VB2005 class namespace? |
|||||||||||||||||||||||