473,473 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to override only Get or only Set?

Hello, Group,

I have been curious about a statement I see occasionally in the VB
(v2003) help. Sometimes the information about a property will indicate
that it is overridable, and I have been making use of this. Sometimes
there is also a statement such as:

"You are not required to override both the get and set methods of the
.... property; you can override only one if needed."

Can anyone tell me how I can override just one of these?

So far, my practice has been to override the "entire" property, and
simply invoke the base property for the piece that I don't need to
adjust. Is there a "better" way?

Cheers,
Randy

Jun 14 '06 #1
4 1970
why do you need to override only one of them?
any reasons?

"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl...
Hello, Group,

I have been curious about a statement I see occasionally in the VB (v2003)
help. Sometimes the information about a property will indicate that it is
overridable, and I have been making use of this. Sometimes there is also
a statement such as:

"You are not required to override both the get and set methods of the ...
property; you can override only one if needed."

Can anyone tell me how I can override just one of these?

So far, my practice has been to override the "entire" property, and simply
invoke the base property for the piece that I don't need to adjust. Is
there a "better" way?

Cheers,
Randy

Jun 14 '06 #2
CT
> So far, my practice has been to override the "entire" property, and simply
invoke the base property for the piece that I don't need to adjust.
Well, that's how I do it too. :-) Well, at least in VB where I believe there
is no other way. It is possible in C# though, so perhaps the note is about
C# and possibly other .NET Framework dev languages?

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl... Hello, Group,

I have been curious about a statement I see occasionally in the VB (v2003)
help. Sometimes the information about a property will indicate that it is
overridable, and I have been making use of this. Sometimes there is also
a statement such as:

"You are not required to override both the get and set methods of the ...
property; you can override only one if needed."

Can anyone tell me how I can override just one of these?

So far, my practice has been to override the "entire" property, and simply
invoke the base property for the piece that I don't need to adjust. Is
there a "better" way?

Cheers,
Randy

Jun 14 '06 #3
Hello, Annie,

There are several reasons why I might do this. One example would be to
limit the Set property to a sub-set of possible values. Sometimes I
will throw an exception, effectively making the Set property Read-Only
(or Write-once). Sometimes it's only the behaviour of the Get that I
want to modify.

But invoking the base class property for the "other" half of a Get-Set
combination is pretty easy, so I don't really "need" to do it. It's as
much a question of curiosity as it is wanting to save typing that one
short line.

Cheers,
Randy
Annie wrote:
why do you need to override only one of them?
any reasons?

"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in message
news:44***********************@news.wanadoo.nl...
Hello, Group,

I have been curious about a statement I see occasionally in the VB (v2003)
help. Sometimes the information about a property will indicate that it is
overridable, and I have been making use of this. Sometimes there is also
a statement such as:

"You are not required to override both the get and set methods of the ...
property; you can override only one if needed."

Can anyone tell me how I can override just one of these?

So far, my practice has been to override the "entire" property, and simply
invoke the base property for the piece that I don't need to adjust. Is
there a "better" way?

Cheers,
Randy


Jun 14 '06 #4
Hi, CT,

Thanks for your reply. Yes, I imagine that you're correct, that the
note applies to other languages, but not to VB. (Maybe in the future.)

Cheers,
Randy
CT wrote:
So far, my practice has been to override the "entire" property, and simply
invoke the base property for the piece that I don't need to adjust.

Well, that's how I do it too. :-) Well, at least in VB where I believe there
is no other way. It is possible in C# though, so perhaps the note is about
C# and possibly other .NET Framework dev languages?

Jun 14 '06 #5

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

Similar topics

5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
8
by: JPRoot | last post by:
Hi M. Jeffrey Tan, Just hopping you didn't forget me? :) Thanks JPRoot ----- \"Jeffrey Tan\" wrote: -----
5
by: Darius | last post by:
I'm writing here in hopes that someone can explain the difference between the new and virtual/override keywords in C#. Specifically, what is the difference between this: public class Window {...
4
by: Jazper Manto | last post by:
hi what is the difference between virtual / override and new? until now i only knew the virtual / override thing. thanx for hint. Jazper //--- new ----------------------------------------...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
5
by: Mark Broadbent | last post by:
Oh yes its that chestnut again! Ive gone over the following (http://www.yoda.arachsys.com/csharp/faq/ -thanks Jon!) again regarding this subject and performed a few of my own tests. I have two...
5
by: Marcel Hug | last post by:
Hi NG ! I'm new in C# and I'm reading a book about the fundamentals and concepts. In the chapter Methods it's written to use virtual, if i would like to override the method in a subclass. This...
9
by: Ben Voigt | last post by:
Found another variation on my previous bug (https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100917) I would welcome validation and votes. class...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.