473,387 Members | 1,493 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,387 software developers and data experts.

ReadOnly Property Inheritance

I am trying to create a read-only interface for an object.

Say I have a Part, which I want to Implement IReadOnlyPart.
IReadOnlyPart will have

ReadOnly Property PartNumber() As String

And I *want* Part to have

Public Property PartNumber() As String Implements
IPart.PartNumber
Get
Return partNumberValue
End Get
Set(ByVal value As String)
partNumberValue = value
End Set
End Property

But that is a compile error "Error 72 'PartNumber' cannot implement
'PartNumber' because there is no matching property on interface
'IPart'."

Is there any way to get this to work or is this simply not How Things
Are Done.

Thanks,

James Thigpen
Feb 27 '08 #1
4 1867
<Ja*************@gmail.comschrieb:
>I am trying to create a read-only interface for an object.

Say I have a Part, which I want to Implement IReadOnlyPart.
IReadOnlyPart will have

ReadOnly Property PartNumber() As String

And I *want* Part to have

Public Property PartNumber() As String Implements
IPart.PartNumber
Get
Return partNumberValue
End Get
Set(ByVal value As String)
partNumberValue = value
End Set
End Property

But that is a compile error "Error 72 'PartNumber' cannot implement
'PartNumber' because there is no matching property on interface
'IPart'."

Is there any way to get this to work or is this simply not How Things
Are Done.
Unfortunately what you want to archieve is not supported by the VB compiler.
You may want to implement the 'Set' part as a function instead ('Function
SetPartNumber').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 27 '08 #2
Ok, Thanks. Does C# let you do this or is it a .net idiom?

James

On Feb 27, 12:18 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
<James.R.Thig...@gmail.comschrieb:
I am trying to create a read-only interface for an object.
Say I have a Part, which I want to Implement IReadOnlyPart.
IReadOnlyPart will have
ReadOnly Property PartNumber() As String
And I *want* Part to have
Public Property PartNumber() As String Implements
IPart.PartNumber
Get
Return partNumberValue
End Get
Set(ByVal value As String)
partNumberValue = value
End Set
End Property
But that is a compile error "Error 72 'PartNumber' cannot implement
'PartNumber' because there is no matching property on interface
'IPart'."
Is there any way to get this to work or is this simply not How Things
Are Done.

Unfortunately what you want to archieve is not supported by the VB compiler.
You may want to implement the 'Set' part as a function instead ('Function
SetPartNumber').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Feb 27 '08 #3
On Feb 27, 4:06 pm, James.R.Thig...@gmail.com wrote:
Ok, Thanks. Does C# let you do this or is it a .net idiom?

James

On Feb 27, 12:18 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-

h...@gmx.atwrote:
<James.R.Thig...@gmail.comschrieb:
>I am trying to create a read-only interface for an object.
Say I have a Part, which I want to Implement IReadOnlyPart.
IReadOnlyPart will have
ReadOnly Property PartNumber() As String
And I *want* Part to have
Public Property PartNumber() As String Implements
IPart.PartNumber
Get
Return partNumberValue
End Get
Set(ByVal value As String)
partNumberValue = value
End Set
End Property
But that is a compile error "Error 72 'PartNumber' cannot implement
'PartNumber' because there is no matching property on interface
'IPart'."
Is there any way to get this to work or is this simply not How Things
Are Done.
Unfortunately what you want to archieve is not supported by the VB compiler.
You may want to implement the 'Set' part as a function instead ('Function
SetPartNumber').
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
It's a CLR thing so it's not just VB.

Thanks,

Seth Rowe [MVP]
Feb 27 '08 #4
Seth --

"rowe_newsgroups" <ro********@yahoo.comschrieb:
>I am trying to create a read-only interface for an object.
Say I have a Part, which I want to Implement IReadOnlyPart.
IReadOnlyPart will have
ReadOnly Property PartNumber() As String
And I *want* Part to have
Public Property PartNumber() As String Implements
IPart.PartNumber
Get
Return partNumberValue
End Get
Set(ByVal value As String)
partNumberValue = value
End Set
End Property
But that is a compile error "Error 72 'PartNumber' cannot implement
'PartNumber' because there is no matching property on interface
'IPart'."
Is there any way to get this to work or is this simply not How Things
Are Done.
Unfortunately what you want to archieve is not supported by the VB
compiler.
You may want to implement the 'Set' part as a function instead
('Function
SetPartNumber').

It's a CLR thing so it's not just VB.
No, it's actually a VB limitation. C# lets you do it.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 27 '08 #5

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

Similar topics

10
by: GP | last post by:
Is it possible to iterate through all the controls collection and make the textboxes alone as read only.I don't see a readonly property for the Control.Can some one help me in this context? I...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
2
by: Marcin Floryan | last post by:
I am creating a custom control (Inherits UserControl) and my control containt a TextBox control. TextBox control has a Property called "ReadOnly". I would like to expose this property outside my...
7
by: DareDevil | last post by:
I have written a method that should modify the folder path passed to it into one that exists and is selected by the user. It then returns a boolean depending on whether a folder path was selected by...
3
by: Tom | last post by:
I'm using the PropertyGrid, and have it bound to a class object. Works fine - however, I have some properties that I want to show up on the grid (i.e. they are browsable) -YET- I don't want the...
2
by: miben | last post by:
I need to set a variable returned by a readonly property in a class by another class. So the only way to set that value is from a specific class and function. Public Sub Main Dim setter As New...
6
by: Roberto | last post by:
Hi, using vb 2005 I'd like to have a combobox in READONLY mode, like I have for textbox. Combobox only has enabled property. When I turn this property false I can not select the text in the...
0
by: Tom Dacon | last post by:
Oops, what I gave you in my first response was the usual way that you use varying scope: Private _FieldValue As <some type> Public Property Something As <some type> Get Return _FieldValue...
0
by: Simon Woods | last post by:
Hi I was struggling to find a suitable place to ask this question, so if it is not appropriate here and someone can suggest somewhere else please do. My question is concerning IOC containers...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.