title: Calling async method in IEnumerable.Select
body: <p>I have the following code, converting items between the types <code>R</code> and <code>L</code> using an async method:</p>
  
  <pre><code>class MyClass&lt;R,L&gt; {
  
      public async Task&lt;bool&gt; MyMethodAsync(List&lt;R&gt; remoteItems) {
          ...
  
          List&lt;L&gt; mappedItems = new List&lt;L&gt;();
          foreach (var remoteItem  in remoteItems )
          {
              mappedItems.Add(await MapToLocalObject(remoteItem));
          }
  
          //Do stuff with mapped items
  
          ...
      }
  
      private async Task&lt;L&gt; MapToLocalObject(R remoteObject);
  }
  </code></pre>
  
  <p>Is this possible to write using an IEnumerable.Select call (or similar) to reduce lines of code? I tried this:</p>
  
  <pre><code>class MyClass&lt;R,L&gt; {
  
      public async Task&lt;bool&gt; MyMethodAsync(List&lt;R&gt; remoteItems) {
          ...
  
          List&lt;L&gt; mappedItems = remoteItems.Select&lt;R, L&gt;(async r =&gt; await MapToLocalObject(r)).ToList&lt;L&gt;();
  
          //Do stuff with mapped items
  
          ...
      }
  }
  </code></pre>
  
  <p>But i get error:</p>
  
  <blockquote>
    <p>"Cannot convert async lambda expression to delegate type
    <code>'System.Func&lt;R,int,L&gt;'</code>. An async lambda expression may return <code>void</code>,
    <code>Task</code> or <code>Task&lt;T&gt;</code>, none of which are convertible to
    <code>'System.Func&lt;R,int,L&gt;'</code>."</p>
  </blockquote>
  
  <p>I believe i am missing something about the async/await keywords, but i cannot figure out what. Does any body know how i can modify my code to make it work?</p>