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 7 1166
Declare the event as being protected or friend, depending on your exact
needs.
"OpticTygre" <op********@adelphia.net> wrote in message
news:8e********************@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?
"Marina" <so*****@nospam.com> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl... Declare the event as being protected or friend, depending on your exact needs.
"OpticTygre" <op********@adelphia.net> wrote in message news:8e********************@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
"Marina" <so*****@nospam.com> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl... Declare the event as being protected or friend, depending on your exact needs.
"OpticTygre" <op********@adelphia.net> wrote in message news:8e********************@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.
"OpticTygre" <op********@adelphia.net> wrote in message
news:mp********************@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" <so*****@nospam.com> wrote in message news:u0**************@TK2MSFTNGP10.phx.gbl... Declare the event as being protected or friend, depending on your exact needs.
"OpticTygre" <op********@adelphia.net> wrote in message news:8e********************@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.
"Marina" <so*****@nospam.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl... BindIP has to be declared protected in A.
"OpticTygre" <op********@adelphia.net> wrote in message news:mp********************@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" <so*****@nospam.com> wrote in message news:u0**************@TK2MSFTNGP10.phx.gbl... Declare the event as being protected or friend, depending on your exact needs.
"OpticTygre" <op********@adelphia.net> wrote in message news:8e********************@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.
"OpticTygre" <op********@adelphia.net> schreef in bericht
news:8e********************@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
"OpticTygre" <op********@adelphia.net> wrote in message
news:05********************@adelphia.com... Which is no good, as I don't have access to the code in A. It is a pre-compiled dll.
"Marina" <so*****@nospam.com> wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl... BindIP has to be declared protected in A.
"OpticTygre" <op********@adelphia.net> wrote in message news:mp********************@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" <so*****@nospam.com> wrote in message news:u0**************@TK2MSFTNGP10.phx.gbl... Declare the event as being protected or friend, depending on your exact needs.
"OpticTygre" <op********@adelphia.net> wrote in message news:8e********************@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 > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: harrylmh |
last post by:
Hi,
I'm learning C# and I just don't quite understand the need for
polymorphism. why do we need to use it? how does a base class variable
holding a derived class instance do any good?
Also,...
|
by: Allen Anderson |
last post by:
Just curious if there is a way to hide a public member inherited from
another class. I know you can 'new' to give it your own version, but
is there a way to make it no longer public period? I...
|
by: Microsoft |
last post by:
Base class:
class AssetBase
{
string _clli;
public string CLLI
{
get
|
by: Baski |
last post by:
Base class:
class AssetBase
{
string _clli;
public string CLLI
{
get
|
by: bob |
last post by:
Hi,
I know there exists a good reason why the designers of c++ decided that
function hiding should exist. But I don't know why. Can anybody provide
a good reason/example of a case where function...
|
by: SpotNet |
last post by:
Hello NewsGroup,
I have a base class and six classes that inherit from this base class. All
members in the base class are used in it's extended classes except, in one
of the extended class one...
|
by: Dom |
last post by:
Hi all
I'm developing a control, and I need to hide some properties to the
user. For example, suppose I need Text property to be completely
inacessible (from a Form/Code that is into another...
|
by: Andrew Robinson |
last post by:
I have class A which inherits from class B. B contains the following virtual
method:
public virtual List<TSelect()
{
return new List<T>();
}
Is there any way to make private or otherwise...
|
by: Aflj |
last post by:
This code won't compile (two compilers tried, gcc and VC++, both of recent versions, but I don't remember them exactly):
class C1
{
public:
void M1(int i) {}
};
class C2: public C1
|
by: developer.new |
last post by:
Hi
I have a question regarding this concept I learned about recently:
Name Hiding. Here's what I've come across:
There is a base class with two functions with the same name but
different...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |