Property's public get and pretected set. Can I do it?

  • Thread starter Thread starter ThunderMusic
  • Start date Start date
T

ThunderMusic

Hi,
The behavior I want to have is the following. For a property of my
class, I want the derived classes to be able to set it, but I don't want
instances of the class to be able to set it. I tried to split the property
by puting the Get section in public and the set section in protected, but it
is not allowed by the compiler. Is there a solution?

thanks
 
This is a new feature in the next version of vb.net 2005 but is not
available with the current 2003 version.

Create a sub for the setter instead of a real property.

Sam
 
Just a idea. Not the prettiest solution to your problem but it will work.
The users of your class can only set it it, and they can only instantiate
the public class. Let me know if this work.

Friend Class TestGetSet
Public Property TestGetSet() As Boolean
Get
End Get
Set(ByVal Value As Boolean)
End Set
End Property
End Class
Public Class TestReadOnly
Shadows ReadOnly Property TestGetSet() As Boolean
Get
End Get
End Property
End Class

Chris
 
Errrr, nevermind.... not my day today. You can not inherit from a friend
class because it would expand the access of the class. I forgot to put the
inherits line in my haste to create it. Sorry

Chris
 
Ok, I went with your solution.

When is VS2005 due? Will it cost about the same price as VS 2003? will the
code be compatible (for most of it)? Is there a page where I can find the
info?

thanks
 

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

Back
Top