title: Getting type of items of a List at run-time in c#
body: <p>I need an expression that gets type of every item of a collection.</p>
  
  <p>I have a collection like this:</p>
  
  <pre><code>var collection = new List&lt;object&gt;{1,2.2,"string",'c'};
  </code></pre>
  
  <p>It's possible to get type of every item of collection like this:</p>
  
  <pre><code>var myVariable= collection.Select(item =&gt; item.GetType())
  </code></pre>
  
  <p>But I need creation of this expression at run-time.
  I have to create something like <code>myVariable</code> dynamically, but how?!</p>
  
  <p>Debugger shows me value of internal expression of <code>myVariable</code> like this:</p>
  
  <pre><code>{System.Linq.Enumerable+WhereSelectListIterator`2[System.Object,System.Type]}
  </code></pre>
  
  <p><strong>EDIT1</strong></p>
  
  <p>Explanation of problem:
  Assume that I need to select one property of an object. I cat write this query like this:</p>
  
  <pre><code>var lst = new List&lt;MyClass&gt;
          {
              new MyClass {Name = "myName1", Value = 1},
              new MyClass {Name = "myName2", Value = 2}
          };
          var oneProperty = lst.Select(item =&gt; new {SelectedProp=item.Name});
  </code></pre>
  
  <p>result is a list of type anonymous contains 2 items: "myName1"&amp;"myName2".
  Now I want to add another property to resulted list that shows the type of selected property. The following code gets me thus list:</p>
  
  <pre><code>            var oneProperty = lst.Select(item =&gt; new {SelectedProp=item.Name,TypeOfProp=item.GetType() });
  </code></pre>
  
  <p>The problem is to create such expression at run-time to give the expression to entity framework and it executes the expression. Is the problem cleared?</p>