title: C# Get Type of IEnumerable<TModel>
body: <p>I have a method to which I pass an <code>IEnumerable&lt;TModel&gt;</code>. Then depending on the type of <code>TModel</code>, the method carries out a set of instructions as below:</p>
  
  <pre><code>    public void MyMethod&lt;TModel&gt;(IEnumerable&lt;TModel&gt; items) where TModel : class
      {
          int operationType;
          switch (typeof(TModel))
          {
              case typeof(MyModelOne):
                  operationType = 1;
                  break;
              case typeof(MyModelTwo):
                  operationType = 2;
                  break;
              case typeof(MyModelThree):
                  operationType = 3;
                  break;
              default:
                  throw new Exception("The collection model passed to MyMethod is not recognized");
          }
          ...
      }
  </code></pre>
  
  <p>This doesnt work, I get the error:</p>
  
  <p><strong>There is no application variable or memeber 'TModel'</strong></p>