Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获取属性树的跟踪?_C#_.net_Properties_Path_Trace - Fatal编程技术网

C# 如何获取属性树的跟踪?

C# 如何获取属性树的跟踪?,c#,.net,properties,path,trace,C#,.net,Properties,Path,Trace,假设我有这样的东西: class Program { static void Main(string[] args) { A A1 = new A(); A1.B1.C1.GetPath(); } } class A { public B B1 { get; set; } public B B2 { get; set; } } class B { public C C1 { get; set; } } class

假设我有这样的东西:

class Program
{
    static void Main(string[] args)
    {
        A A1 = new A();
        A1.B1.C1.GetPath();
    }
}

class A
{
    public B B1 { get; set; }
    public B B2 { get; set; }
}

class B
{
    public C C1 { get; set; }
}
class C
{
    public string GetPath();
}

是否有可能实现方法GetPath,例如返回A1中B1中的C1?

没有内置的方法来实现这一点

您可以做的是:

OOP方式:定义传递父/持有者类引用的ctor,以便在运行时计算出来

使用和获取堆栈跟踪不知道这是否符合您的实际需要


希望这能有所帮助。

实现这一点没有内在的方法

您可以做的是:

OOP方式:定义传递父/持有者类引用的ctor,以便在运行时计算出来

使用和获取堆栈跟踪不知道这是否符合您的实际需要

希望这有帮助。

相关:相关: