Re: Get all parent/childs
You use GetType to get an object's type. You use GetProperties to get a type's properties. You use GetValue to get a property's value. And so on, and so on, and so on...
Re: Get all parent/childs
sorry. my question was not that clear
basically I want to go through each and every single parent/children from the given object
how can i get to the "root" parent from a child entity?
Re: Get all parent/childs
Quote:
Originally Posted by Techno
how can i get to the "root" parent from a child entity?
You wouldn't, unless the "child" has some property that refers to the "parent". For instance, consider this:
CSharp Code:
public class Class1
{
private Class2 someField;
public Class2 SomeProperty
{
get
{
return someField;
}
set
{
someField = value;
}
}
}
public class Class2
{
//...
}
CSharp Code:
Class1 c1 = new Class1();
Class2 c2 = new Class2();
c1.SomeProperty = c2;
Now, the Class2 object has no reference to the Class1 object. It has no idea the Class1 object even exists. How could you possibly get to c1 from c2?