title: Unable to pass IEnumerable<string> as parameter in Expression.Call
body: <p>This is my class:</p>
  
  <pre><code>class SampleExpression
  {
      public static void SampleEnum(IEnumerator&lt;string&gt; ien)
      {
          while (ien.MoveNext())
          {
              Console.WriteLine(ien.Current);
          }
      }
  }
  </code></pre>
  
  <p>This is how i am trying to invoke the <code>SampleEnum</code> method:</p>
  
  <pre><code>    public void Main(string[] args)
      {
          ParameterExpression param2 = Expression.Parameter(typeof(SampleExpression), "args");
  
          var lstConstant = "1,2,3,4,".Split(new string[] { "," },
                                                  StringSplitOptions.RemoveEmptyEntries).ToList();
  
          Expression ep = Expression.Constant(Expression.Constant(lstConstant, typeof(IEnumerable&lt;string&gt;)));
          var enummethod = typeof(SampleExpression).GetMethod("SampleEnum");
          MethodCallExpression methodCall = Expression.Call
                                          (
                                              enummethod
                                              , ep
                                          );
  
          var e = Expression.Lambda&lt;Func&lt;IEnumerator&lt;string&gt;, string&gt;&gt;(methodCall, param2);
          e.Compile()(lstConstant.GetEnumerator());
      }
  </code></pre>
  
  <p>I get the following error in the line which tries to create the method call expression:</p>
  
  <blockquote>
    <p>Expression of type 'System.Linq.Expressions.TypedConstantExpression' cannot be used for parameter of type 'System.Collections.Generic.IEnumerator<code>1[System.String]' of method 'Void Enum(System.Collections.Generic.IEnumerator</code>1[System.String])'</p>
  </blockquote>
  
  <p>Please help.</p>