title: C# Reflection with recursion
body: <p>I am working on the Reflection , but i am stuck while doing the recursion.</p>
  
  <p>Code :</p>
  
  <pre><code>public class User {
    public string Name;
    public int Number;
    public Address Address;    
  }
  
  
  public class Address {
   public string Street;
   public string State;
   public string Country;
  }
  </code></pre>
  
  <p>now i am printing the values.</p>
  
  <pre><code> Type t = user.GetType();  
   PropertyInfo[] props = t.GetProperties(); 
   foreach (PropertyInfo prp in props)  
   {  
     if(!prp.GetType().IsPrimitive &amp;&amp; prp.GetType().IsClass) 
     {
       // Get the values of the Inner Class.
       // i am stucked over here , can anyone help me with this.
  
             Type ty = prp.GetType();
             var prpI = ty.GetProperties();
             //var tp = ty.GetType().;
              foreach (var propertyInfo in prpI)
              {
              var value = propertyInfo.GetValue(prp);
              var stringValue = (value != null) ? value.ToString() : "";
              console.WriteLine(prp.GetType().Name + "." + propertyInfo.Name+" Value : " +stringValue);    
              }
     }
     else
     {    
       var value = prp.GetValue(user);   
       var stringValue = (value != null) ? value.ToString() : "";
       console.writeline(user.GetType().Name + "." + prp.Name+" Value : " +stringValue); 
     }
   }
  </code></pre>
  
  <p>i want to know how to find out whether the property is a class or the primitive. and do the recursion if it is a class.</p>