I have a complex class hierarchy: class B is an attribute of class A, List(class C) and class D are attributes of class B, etc - lots of levels of parent-child relationship. Some classes in the hierarchy has string attribute "foobar". Some classes don't. I have an instanse of class A. I need to find all objects in the hierarchy which has attribute "foobar", and change its value to "qwerty". Is there a simple way to do that in C#?
public class ClassD
{
public string fooBar;
}
public class ClassC
{ }
public class ClassB
{
public List<ClassC> classCList;
public ClassD classDInstance;
public string fooBar;
}
public class ClassA
{
public ClassB classBInstance;
}