如何在C#中打印对象图 [英] How to Print Object Graph in C#
本文介绍了如何在C#中打印对象图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要打印对象层次结构。让我们假设下面有三个类。
I have a requirement where i need to print object hierarchy.Let us assume three classes below.
class Test
{
public string Name{get;set;}
public Test1 Test1{get;set;}
}
class Test1
{
public string Name{get;set;}
public List<test2> Test2{get;set;}
}
class Test2
{
public string Name{get;set;}
}
代码应该是通用的,并提供如下输出。
Test.Name
Test.Test1.Name
Test.Test1 .Test2.Name
请帮帮我。
The code should be generic and give output as below.
Test.Name
Test.Test1.Name
Test.Test1.Test2.Name
Please help me.
推荐答案
看看这里:http://blog.aggregatedintelligence.com/2011/06/cobjectdumper.html [ ^ ]
这篇关于如何在C#中打印对象图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文