title: Integer List not getting converted to Datatable C#
body: <p>I want to convert a <strong>List</strong> to a Datatable. I am using the following code :</p>
  
  <pre><code>public static DataTable ConvertToDataTable(object o)
      {
          DataTable dt = new DataTable("OutputData");
  
          DataRow dr = dt.NewRow();
          dt.Rows.Add(dr);
  
          o.GetType().GetProperties().ToList().ForEach(f =&gt;
          {
              try
              {
                  f.GetValue(o, null);
                  dt.Columns.Add(f.Name, f.PropertyType);
                  dt.Rows[0][f.Name] = f.GetValue(o, null);
              }
              catch { }
          });
          return dt;
      }
  </code></pre>
  
  <p>The following is the class object that I am trying to pass to the ConverToDataTable method :</p>
  
  <pre><code>   public class Class1
     {
  
      private List&lt;int&gt; _intList;
  
  
      public List&lt;int&gt; intList
      {
          get
          {
              return _intList;
          }
          set
          {
              _intList = value;
          }
      }
  }
  </code></pre>
  
  <p>But when I am trying to convert the class1 object to DataTable I am getting the datatable columns as count and Capacity.. What am I doing wrong?</p>