Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a requirement where i need to print object hierarchy.Let us assume three classes below.
C#
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;}
}

The code should be generic and give output as below.
Test.Name
Test.Test1.Name
Test.Test1.Test2.Name

Please help me.
Posted
Updated 15-Feb-15 9:44am
v4
Comments
Zoltán Zörgő 15-Feb-15 14:10pm    
And what have you tried?
BillWoodruff 15-Feb-15 14:38pm    
Unless you tell us how you are reading the code in order to print it, I don't think I can help. Usually the word Object Graph is used to describe some Objects that have relationships, like is-a, has-a, inherits-from, shares-interface-with etc. In the more formal sense of the word "Object Graph" can mean Nodes, Properties, Edges (relationships).

What do you mean by "Object Graph" ?
Zoltán Zörgő 15-Feb-15 15:38pm    
Well?

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900