Properties: Catch 22

P

pbd22

Hi. I am caught between 2 errors.

When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property



I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.


And, when I have:

Public ReadOnly Property Subtitle() As String
Get
Return _subTitle
End Get
End Property

Public WriteOnly Property Subtitle() As String
Set(ByVal value As String)
_subTitle = Value
End Set
End Property



I get:

Quote:
Error 22 'Public ReadOnly Property Subtitle() As String' and 'Public
WriteOnly Property Subtitle() As String' cannot overload each other
because they differ only by 'ReadOnly' or 'WriteOnly'.


help?
 
B

Branco Medeiros

pbd22 wrote:
When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.
<snip>

The implementing method doesn't need to be named after the implemented
one. Therefore, you can have:
Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

Private ReadOnly Property IWebPart_SubTitle As String _
Implements System.Web.UI.WebControls._
WebParts.IWebPart.SubTitle
Return Subtitle
End Property


HTH.

Regards,

Branco
 
P

Pritcham

Hi. I am caught between 2 errors.

When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.

And, when I have:

Public ReadOnly Property Subtitle() As String
Get
Return _subTitle
End Get
End Property

Public WriteOnly Property Subtitle() As String
Set(ByVal value As String)
_subTitle = Value
End Set
End Property

I get:

Quote:
Error 22 'Public ReadOnly Property Subtitle() As String' and 'Public
WriteOnly Property Subtitle() As String' cannot overload each other
because they differ only by 'ReadOnly' or 'WriteOnly'.

help?

Hi

Just for your future reference, the error message you were getting
tells you all you need to know - i.e.
The first part ("Error 21 Class 'WebPartBase' must implement 'ReadOnly
Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. "

is telling you that you need to implement the ReadOnly Property
SubTitle().

The second part ("Implementing property must have matching 'ReadOnly'
or 'WriteOnly' specifiers.") is a more generic message telling you
that you have a mismatched property so you need to match it.

Hope that helps
Martin
 
C

Chris Dunaway

Hi. I am caught between 2 errors.

When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.

And, when I have:

Public ReadOnly Property Subtitle() As String
Get
Return _subTitle
End Get
End Property


The Subtitle property on the IWebPart interface is just a read only
property. Just get rid of the WriteOnly property, you don't need
it.

Chris
 
P

pbd22

The Subtitle property on the IWebPart interface is just a read only
property. Just get rid of the WriteOnly property, you don't need
it.

Chris


Thanks all, much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top