title: Class property name and its data type for sub class using Reflection
body: <p>I am trying to get class property name and its data type dynamically for any class so that I can build schema model required for Db e.g. Google BigQuery.
  I was able to get the string or int property name and Type but with array or list of custom class am not sure how to get their class property and name.</p>
  
  <p>My model is :</p>
  
  <pre><code>public class StateModel
  {
      public string State { get; set; }
      public string Gender { get; set; }
      public int Year { get; set; }
      public string Name { get; set; }
      public int Number { get; set; }
  
      public int[] Items { get; set; }
      public List&lt;string&gt; Values { get; set; }
  
      public Coordinate[] OrdinateArray { get; set; }
      public List&lt;Coordinate&gt; Ordinates { get; set; }
  
      public Coordinate CoordinateObj { get; set; }
  }
  
  public class Coordinate
  {
      public int Point { get; set; }
      public string Value { get; set; }
  }
  </code></pre>
  
  <p>My method to get class property is:</p>
  
  <pre><code>public static Dictionary&lt;string, object&gt; GetColumnFromClass&lt;T&gt;() where T : class, new()
  {
      Dictionary&lt;string, object&gt; fields = new Dictionary&lt;string, object&gt;();
      T obj = new T();
      var type = obj.GetType();    
      PropertyInfo[] properties = type.GetProperties();
      foreach (var item in properties)
      {
          fields.Add(item.Name, item.PropertyType.Name.ToUpper())
      }
      return fields;
  }
  </code></pre>
  
  <p>Can anyone help me how to get Coordinate class details i.e.(Point and Value name of Coordinate class) from the below properties:</p>
  
  <pre><code>public Coordinate[] OrdinateArray { get; set; }
  public List&lt;Coordinate&gt; Ordinates { get; set; }
  public Coordinate CoordinateObj { get; set; }
  </code></pre>
  
  <p>Note: I needed to get the subclass details dynamically and not hard coded.</p>