|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Hiding items in base classesIf I have a Class "B" that Inherits Class "A", and my application uses class
"B", is there a way that I can keep from exposing properties, subs, and events in the Class "A" base class from the application? For example, if Class "A" has a "StateChanged" event that I don't want the application to see, is there a way to hide exposure to that event in Class "B"? Thanks for any help. -Jason Declare the event as being protected or friend, depending on your exact
needs. Show quoteHide quote "OpticTygre" <opticty***@adelphia.net> wrote in message news:8eidnWTiz7_-sdHfRVn-2g@adelphia.com... > If I have a Class "B" that Inherits Class "A", and my application uses > class > "B", is there a way that I can keep from exposing properties, subs, and > events in the Class "A" base class from the application? > > For example, if Class "A" has a "StateChanged" event that I don't want the > application to see, is there a way to hide exposure to that event in Class > "B"? > > Thanks for any help. > > -Jason > > > So in Class "B" I would do something like:
Protected Shadows Event StateChanged(Sender as Object, Args as StateChangedArgs) Or Protected Shadows Property SomeProperty as String Is that right? Show quoteHide quote "Marina" <someone@nospam.com> wrote in message news:u0Te3RhNFHA.1392@TK2MSFTNGP10.phx.gbl... > Declare the event as being protected or friend, depending on your exact > needs. > > "OpticTygre" <opticty***@adelphia.net> wrote in message > news:8eidnWTiz7_-sdHfRVn-2g@adelphia.com... >> If I have a Class "B" that Inherits Class "A", and my application uses >> class >> "B", is there a way that I can keep from exposing properties, subs, and >> events in the Class "A" base class from the application? >> >> For example, if Class "A" has a "StateChanged" event that I don't want >> the >> application to see, is there a way to hide exposure to that event in >> Class >> "B"? >> >> Thanks for any help. >> >> -Jason >> >> >> > > No, that doesn't work, at least for properties.
Class "A" has a property, BindIP that is public and overridable. Class "B" Inherits class "A", thereby inheriting the BindIP property My application uses Class "B", and not Class "A" I don't want my application to know that this BindIP property exists. If I try to say something like "Protected Overrides Property BindIP as String", the code produces an error, because Class A defines BindIP as Public, and I'm trying to redefine it as Protected in Class B. How can I get around that, and keep it hidden from my application? -Jason Show quoteHide quote "Marina" <someone@nospam.com> wrote in message news:u0Te3RhNFHA.1392@TK2MSFTNGP10.phx.gbl... > Declare the event as being protected or friend, depending on your exact > needs. > > "OpticTygre" <opticty***@adelphia.net> wrote in message > news:8eidnWTiz7_-sdHfRVn-2g@adelphia.com... >> If I have a Class "B" that Inherits Class "A", and my application uses >> class >> "B", is there a way that I can keep from exposing properties, subs, and >> events in the Class "A" base class from the application? >> >> For example, if Class "A" has a "StateChanged" event that I don't want >> the >> application to see, is there a way to hide exposure to that event in >> Class >> "B"? >> >> Thanks for any help. >> >> -Jason >> >> >> > > BindIP has to be declared protected in A.
Show quoteHide quote "OpticTygre" <opticty***@adelphia.net> wrote in message news:mpGdnbWe8d1GqdHfRVn-iw@adelphia.com... > No, that doesn't work, at least for properties. > > Class "A" has a property, BindIP that is public and overridable. > Class "B" Inherits class "A", thereby inheriting the BindIP property > My application uses Class "B", and not Class "A" > I don't want my application to know that this BindIP property exists. > > If I try to say something like "Protected Overrides Property BindIP as > String", the code produces an error, because Class A defines BindIP as > Public, and I'm trying to redefine it as Protected in Class B. > > How can I get around that, and keep it hidden from my application? > > -Jason > > > "Marina" <someone@nospam.com> wrote in message > news:u0Te3RhNFHA.1392@TK2MSFTNGP10.phx.gbl... >> Declare the event as being protected or friend, depending on your exact >> needs. >> >> "OpticTygre" <opticty***@adelphia.net> wrote in message >> news:8eidnWTiz7_-sdHfRVn-2g@adelphia.com... >>> If I have a Class "B" that Inherits Class "A", and my application uses >>> class >>> "B", is there a way that I can keep from exposing properties, subs, and >>> events in the Class "A" base class from the application? >>> >>> For example, if Class "A" has a "StateChanged" event that I don't want >>> the >>> application to see, is there a way to hide exposure to that event in >>> Class >>> "B"? >>> >>> Thanks for any help. >>> >>> -Jason >>> >>> >>> >> >> > > Which is no good, as I don't have access to the code in A. It is a
pre-compiled dll. Show quoteHide quote "Marina" <someone@nospam.com> wrote in message news:%23KOYPkhNFHA.576@TK2MSFTNGP15.phx.gbl... > BindIP has to be declared protected in A. > > "OpticTygre" <opticty***@adelphia.net> wrote in message > news:mpGdnbWe8d1GqdHfRVn-iw@adelphia.com... >> No, that doesn't work, at least for properties. >> >> Class "A" has a property, BindIP that is public and overridable. >> Class "B" Inherits class "A", thereby inheriting the BindIP property >> My application uses Class "B", and not Class "A" >> I don't want my application to know that this BindIP property exists. >> >> If I try to say something like "Protected Overrides Property BindIP as >> String", the code produces an error, because Class A defines BindIP as >> Public, and I'm trying to redefine it as Protected in Class B. >> >> How can I get around that, and keep it hidden from my application? >> >> -Jason >> >> >> "Marina" <someone@nospam.com> wrote in message >> news:u0Te3RhNFHA.1392@TK2MSFTNGP10.phx.gbl... >>> Declare the event as being protected or friend, depending on your exact >>> needs. >>> >>> "OpticTygre" <opticty***@adelphia.net> wrote in message >>> news:8eidnWTiz7_-sdHfRVn-2g@adelphia.com... >>>> If I have a Class "B" that Inherits Class "A", and my application uses >>>> class >>>> "B", is there a way that I can keep from exposing properties, subs, and >>>> events in the Class "A" base class from the application? >>>> >>>> For example, if Class "A" has a "StateChanged" event that I don't want >>>> the >>>> application to see, is there a way to hide exposure to that event in >>>> Class >>>> "B"? >>>> >>>> Thanks for any help. >>>> >>>> -Jason >>>> >>>> >>>> >>> >>> >> >> > > Then you are probably out of luck.
The best you can do, as far as i know, is make it 'protected shadows'. However, someone can just do this: CType(myBInstance, A).BindIP Show quoteHide quote "OpticTygre" <opticty***@adelphia.net> wrote in message news:05qdnQxEW6w0qtHfRVn-sw@adelphia.com... > Which is no good, as I don't have access to the code in A. It is a > pre-compiled dll. > > "Marina" <someone@nospam.com> wrote in message > news:%23KOYPkhNFHA.576@TK2MSFTNGP15.phx.gbl... >> BindIP has to be declared protected in A. >> >> "OpticTygre" <opticty***@adelphia.net> wrote in message >> news:mpGdnbWe8d1GqdHfRVn-iw@adelphia.com... >>> No, that doesn't work, at least for properties. >>> >>> Class "A" has a property, BindIP that is public and overridable. >>> Class "B" Inherits class "A", thereby inheriting the BindIP property >>> My application uses Class "B", and not Class "A" >>> I don't want my application to know that this BindIP property exists. >>> >>> If I try to say something like "Protected Overrides Property BindIP as >>> String", the code produces an error, because Class A defines BindIP as >>> Public, and I'm trying to redefine it as Protected in Class B. >>> >>> How can I get around that, and keep it hidden from my application? >>> >>> -Jason >>> >>> >>> "Marina" <someone@nospam.com> wrote in message >>> news:u0Te3RhNFHA.1392@TK2MSFTNGP10.phx.gbl... >>>> Declare the event as being protected or friend, depending on your exact >>>> needs. >>>> >>>> "OpticTygre" <opticty***@adelphia.net> wrote in message >>>> news:8eidnWTiz7_-sdHfRVn-2g@adelphia.com... >>>>> If I have a Class "B" that Inherits Class "A", and my application uses >>>>> class >>>>> "B", is there a way that I can keep from exposing properties, subs, >>>>> and >>>>> events in the Class "A" base class from the application? >>>>> >>>>> For example, if Class "A" has a "StateChanged" event that I don't want >>>>> the >>>>> application to see, is there a way to hide exposure to that event in >>>>> Class >>>>> "B"? >>>>> >>>>> Thanks for any help. >>>>> >>>>> -Jason >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > No.
"When one type inherits from another, it gets all of the members. You can hide members in your inherited type, but you can't get rid of them." - Microsoft documentation. You can 'hide' members with overriding and shadowing. Overriding: "By default, a derived class inherits methods from its base class. If an inherited property or method needs to behave differently in the derived class it can be overridden; that is, you can define a new implementation of the method in the derived class." - Microsoft documentation. Shadowing: "When two programming elements share the same name, one of them can hide - that is, shadow - the other one. In such a situation, the shadowed element is not available for reference; instead, when your code uses the shared name, the Visual Basic compiler resolves it to the shadowing element." - Microsoft documentation. Show quoteHide quote "OpticTygre" <opticty***@adelphia.net> schreef in bericht news:8eidnWTiz7_-sdHfRVn-2g@adelphia.com... > If I have a Class "B" that Inherits Class "A", and my application uses > class > "B", is there a way that I can keep from exposing properties, subs, and > events in the Class "A" base class from the application? > > For example, if Class "A" has a "StateChanged" event that I don't want the > application to see, is there a way to hide exposure to that event in Class > "B"? > > Thanks for any help. > > -Jason > > >
activeX doesn't dispose
ImageList issue unbounded array of objects gets error when instantiating elements delete a record from datagrid Problems with pictureboxes and memory usage detect mouse event on node of a treeview FTP client newbie stupidity: opening one form and closing another How can I loop through all of the messages in the inbox - VB.NET E how to submit a form when enter is pressed |
|||||||||||||||||||||||