I have a problem with a List of objects …
This List contains objects which themselves contain objects, and so on … (all objects are of the same type)
My objects looks like that :
public class MyObject (...)
{
...
public MyObject[] Object;
...
}
I’d like to change some variables of these objects (according to certain parameters), and to do that I think using LINQ.
My problem is that I do not really know how to do something that will pass through ALL my recursive List, regardless of their level.
I hope I was as clear as possible.
Thank you in advance for your help.
You can write a simple recursive method to do what you want easily enough:
If you really, really want a more LINQ-esque method, or you do this often enough to need a more generic approach, you could use something like this:
You could then use it like: