J
Jordan Bowness
I'm trying to develop a bunch of classes and want to do it the right
way.
Say I have 5 classes:
City,
Neighborhood,
NeighborhoodCollection,
House,
HouseCollection
The collection classes are strongly typed collections which inherit
System.Collections.CollectionBase
So once I instanciate everything I need, I may use it as follows:
City.NeighborhoodCollection(2).Housecollection(3).value
So here's my question:
I have a sub in the House class which needs to access some property of
the City class. For example, when calling house.GetAverageIncome(), the
sub needs to know which City the house is in. Make sense?
The only way I was able to figure out how to do this was to pass a
reference down to each child object (when sub new() was called in City,
it populated its NeighborhoodCollection members and created a
NeighborhoodCollection.MyParent reference to itself):
dim NeighborhoodToAdd as Neighborhood = new Neighborhood
NeighborhoodToAdd.MyParent = City
City.NeighborhoodCollection.Add(NeighborhoodToAdd)
This got ugly fast. How should I be referencing the properties in a
class' parent?
Thanks!
================
Jordan Bowness
================
way.
Say I have 5 classes:
City,
Neighborhood,
NeighborhoodCollection,
House,
HouseCollection
The collection classes are strongly typed collections which inherit
System.Collections.CollectionBase
So once I instanciate everything I need, I may use it as follows:
City.NeighborhoodCollection(2).Housecollection(3).value
So here's my question:
I have a sub in the House class which needs to access some property of
the City class. For example, when calling house.GetAverageIncome(), the
sub needs to know which City the house is in. Make sense?
The only way I was able to figure out how to do this was to pass a
reference down to each child object (when sub new() was called in City,
it populated its NeighborhoodCollection members and created a
NeighborhoodCollection.MyParent reference to itself):
dim NeighborhoodToAdd as Neighborhood = new Neighborhood
NeighborhoodToAdd.MyParent = City
City.NeighborhoodCollection.Add(NeighborhoodToAdd)
This got ugly fast. How should I be referencing the properties in a
class' parent?
Thanks!
================
Jordan Bowness
================