我需要创建一个方法,通过嵌套列表中实体的 ID 查找根节点的路径。
public class Application
{
public string Name { get; set; }
public string Path { get; set; }
public List<Component> Components { get; set; }
}
public class Component
{
public string Name { get; set; }
public string Path
public List<Component> Components { get; set; }
}
例如:
-Name: Windows:
-Path: "D:\Windows"
-components:
[0] Path: "Microsoft.net"
Name: ".netfolder"
Components:
[0] Path: "Framework"
Name: ".netfolder"
Components:
[0] Path: "v3.0"
Name: "3.0folder"
Components:
[1] Path: "Microsoft.net"
Name: "Framework64"
Components:
如果我以“3.0folder”作为参数调用该方法,它应该返回每个节点的节点路径:
{ "D:\Windows", "Microsoft.net", "Framework", "v3.0" }