I have a recursive data structure, such as linked list:
class Node
{
private Node next;
private int data;
// (...)
public Node Next
{
get
{
return next;
}
}
public int Data
{
get
{
return data;
}
}
}
I'd like to make a LINQ query, which starts from the head of the list and then goes through the elements, collecting data on the fly. How to do that?
List<Node>on which you want to applyLINQ, or you just have aNodeinstance which hierarchically have more instances ofNodeclass and you want to get data from all objects sequentially from head to tail?Nodeonly. If I hadList<Node>, I could simply use existingLINQextensions :)