Class Property

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have two classes defined as follows:

Public Class Parent
...
Public Class Child
...
End Class
End Class

Parent class has 10 properties which will be used in Child class.

Is it possible to make those properties accessible from child class?

Or do I need to create properties in child class and then "pass" the
values of the Parent properties to child?

Thanks,

Miguel
 
Miguel,
To answer your question, lets take 2 approaches
1. Trying to access the parent's properties in the child class : YES...its
possible...if and only if your property is static. But sadly this would
defeat the whole idea of trying to keep the property in a class in the first
place.

2. Accessing the parent by passing it as a variable : Yes...i think its the
only way to do. I generally pass the properties via an overloaded constructor
in the child class.

HTH
 
there is no special relationship other than namespace/scoping with a
child class. for a child instance to access properties of Parent, it
will need a reference (variable) that references an instance of Parent.

-- bruce (sqlwork.com)
 
Back
Top