title: Retrieve Data From IEnumerable?
body: <p>[CrossPost From MSDN]</p>
  
  <p>I had a task that, I need to send a generic List to a method, where I need to iterate it and convert it to an Excel File. I already did this with Data Table, but with Generic  list I am facing some problems (I don't want to convert my generic list to Data Table). I will paste the code which helps me out for an answer.</p>
  
  <p>I Had Two Generic Lists  </p>
  
  <pre><code>            List&lt;User&gt;       objList = new List&lt;User&gt;();
              List&lt;Student&gt; objStudent = new List&lt;Student&gt;();
  </code></pre>
  
  <p>// I am adding some Item to List</p>
  
  <pre><code>            User obj = new User(1, "aaa");
              User obj1 = new User(2, "bbb");
              User obj2 = new User(3, "ccc");
              User obj3 = new User(4, "ddd");
  
  
              Student sobj = new Student(1, "aaa");
              Student sobj1 = new Student(2, "bbb");
              Student sobj2 = new Student(3, "ccc");
              Student sobj3 = new Student(4, "ddd");
              objList.Add(obj);ExportToExcel(objList);
  </code></pre>
  
  <p>To Export it to Excel , I am passing the lists to the below methods as</p>
  
  <pre><code>    public void ExportToExcel&lt;T&gt;(IEnumerable&lt;T&gt; list)
      {
          PropertyInfo[] piT = typeof(T).GetProperties();
  
          var Users = list.ToList();
  
          Type myType = (typeof(T));
      }
  </code></pre>
  
  <p>When I am passing my list to Ienumerable... I am not able to retrieve the data present in the List IEnumerable list. If I retrieve the data , then I can handle further. Could any one suggest me the better Idea?</p>