473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Implementing an interface?

I'm new to VB.NET, and I am translating an object model from C# to VB.NET,
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
Aug 23 '06 #1
3 1635

David Veeneman domain is my last name wrote:
I'm new to VB.NET, and I am translating an object model from C# to VB.NET,
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 -

Public ReadOnly Property ActiveText() As String Implements
IDrillDown.ActiveText
Get
Return Me.Name
End Get
End Property

HTH,

--
Tom Shelton

Aug 23 '06 #2
Thanks, Tom!
Aug 23 '06 #3
David Veeneman wrote:
The interface is a custom interface, IDrillDown
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.
You have created a method that can implement th Interface's property,
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.
Aug 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Martyn Lawson | last post by:
Hi, I am currently working as an Analyst on a .NET Web Project using ASP.NET and C#.NET. I have a couple of, at least what should be, quick questions: 1. My understanding of UML says that...
4
by: Frank J. Reashore | last post by:
Hello Everyone, I am implementing a simple interface in C# using Visual Studio .net and was quite surprised to discover that the C# compiler does NOT complain if a method on the interface is not...
3
by: Frans Bouma | last post by:
Hi, I have a serious problem with VB.NET and a DataTable derived class and I can't figure out how to solve it. I have implemented it in C# where it works perfectly, but I can't port one...
0
by: Yatin Bhuta | last post by:
Hi, I have an interface in vb 6.0. It has a property set member, which takes a parameter by reference. When I try to implement this interface in my vb.net project it gives me an error saying...
7
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I...
2
by: larzeb | last post by:
I receive the following error from the compiler: ScheduledInfo' must implement 'Property AddrLine1() As String' for interface 'ICASSBatch'. Implementing property must have matching...
0
by: ZA_AJR | last post by:
Hi All I have a class (aClass, derived from aBaseClass) with implements an interface IMyInterface. aClass also has a private member of type aNotherClass which raises various events. I would like...
6
by: Raj Wall | last post by:
Hi, I am trying to implement the IEqualityComparer interface for a struct so I can use it as the Key for a Dictionary. My struct declaration has: public struct Ring : IEqualityComparer {...
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.