|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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 why do you need to override only one of them?
any reasons? Show quoteHide quote "R. MacDonald" <sci***@NO-SP-AMcips.ca> wrote in message news:448ff62e$0$82141$dbd41001@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 > 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: Show quoteHide quote > why do you need to override only one of them? > any reasons? > > "R. MacDonald" <sci***@NO-SP-AMcips.ca> wrote in message > news:448ff62e$0$82141$dbd41001@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 >> > > > > So far, my practice has been to override the "entire" property, and simply Well, that's how I do it too. :-) Well, at least in VB where I believe there > invoke the base property for the piece that I don't need to adjust. is no other way. It is possible in C# though, so perhaps the note is about C# and possibly other .NET Framework dev languages? -- Show quoteHide quoteCarsten 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" <sci***@NO-SP-AMcips.ca> wrote in message news:448ff62e$0$82141$dbd41001@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 > 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: Show quoteHide quote >>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? >
Is this Possible ?
The big Debate on DoEvents How to easily create useful data-entry forms in vb.net? Changing datagridview cell borders at runtime DataBase Programming How do you see if a table already exists in a database? How to easily create data-entry forms in vb.net How can I get Windows user, password and domain? How to use Compressed Folder function of XP programmatically? Showing hourglass cursor for entire screen, not just program window |
|||||||||||||||||||||||