So, the solution is to have a property of Cat that has a property of
TheHouse such as Cat.ContainingCatHouse .. So when generating
CatHouse.TheCat in the class CatHouse I would have to set a by reference
value such as TheCat.ContainingCatHouse = this .. To recreate the classes:
class CatHouse {
public Cat TheCat;
public bool HasCarpet;
private void createTheCat() {
TheCat = new Cat();
TheCat.ContainingCatHouse = this;
}
}
class Cat {
public string CatName;
public CatHouse ContainingCatHouse;
private bool checkForCarpetOnCatHouse() {
return this.ContainingCatHouse.HasCarpet;
}
}
This sounds a little redundant and can create a little nightmare, but if
this is the solution, I can work with it.
--
Jay Douglas
Fort Collins, Colorado
http://www.jaydouglas.com
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:KbEPc.69563$8_6.418@attbi_s04...
Let me make sure I understand you:
You have an object. You want to find the object that refers to it as a
property, so that you can discover the value of ANOTHER property of the
containing object. Is that right?
Answer: you have a design issue.
If it is important for a cat to know what cat house it is inside, it
should have a reference to the cat house. Otherwise, the house that the cat is
in is not a property of the cat, and is not discoverable from it.
Hope this helps,
--- Nick
"Jay Douglas" <ja****************@squarei.com> wrote in message
news:eU**************@tk2msftngp13.phx.gbl... I'm not to sure how to phrase this question. I need to know how to call
a property of an object that contains an object. I'll use PetHouse and
Cat for an example. (I didn't use get or set to try to keep it simple and
short)
class CatHouse {
public Cat TheCat;
public bool HasCarpet;
}
class Cat {
public string CatName;
}
What I need to know is: From the TheCat object, how do I retrieve the
value of a property in CatHouse (i.e. CatHouse.HasCarpet)?
--
Jay Douglas
Fort Collins, Colorado
http://www.jaydouglas.com