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

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

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
Nov 21 '05 #1
5 981

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
On Tue, 25 Jan 2005 11:24:09 -0500, "ThunderMusic"
<NO*******@sympatico.caSPAMATALL> wrote:
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


Nov 21 '05 #2
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

"ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
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

Nov 21 '05 #3
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

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:OC*************@TK2MSFTNGP12.phx.gbl...
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

"ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
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


Nov 21 '05 #4
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

"Samuel R. Neff" <bl****@newsgroup.nospam> a écrit dans le message de
news:24********************************@4ax.com...

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
On Tue, 25 Jan 2005 11:24:09 -0500, "ThunderMusic"
<NO*******@sympatico.caSPAMATALL> wrote:
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 propertyby puting the Get section in public and the set section in protected, but itis not allowed by the compiler. Is there a solution?

thanks

Nov 21 '05 #5
When is VS2005 due?
This year. There's a beta and various other prerelease versions
available now, and another beta coming up in the next couple of
months.

Will it cost about the same price as VS 2003?
I don't think any pricing has been announced.

will the code be compatible (for most of it)?
Yes

Is there a page where I can find the info?


http://www.msdn.com/vs2005/

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #6

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

Similar topics

7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
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...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
0
by: Jordan Bowness | last post by:
I make a similar post in another newsgroup, but this example is simplified somewhat. I have a component (cmpMyComponent) with 2 properties. The 1st property is a string value (Description) and...
6
by: Altman | last post by:
I would like to use an indexed property to access my private array of user controls. If I don't use an indexed property, the property will show up in my Properties Window during development. Is...
2
by: Lespaul36 | last post by:
I have a control that I have made that uses a custom class for storage of some of the information. I want it to display in the VS.Net 2003 property grid in the IDE like the Font property does, so...
11
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
1
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.