title: Return either an in-memory (cached) collection, or a task from an async await response
body: <p>I have a scenario where my service class communicates to an API and populates a list. This method is</p>
  
  <pre><code> public async Task&lt;List&lt;T&gt;&gt; Foo()
  </code></pre>
  
  <p>and in this method I am doing an async await to retrieve data from the API and deserialize to a list.</p>
  
  <p>The thing is, I'd like to do something like this:</p>
  
  <pre><code>if (list is cached in memory)
     //serve data from the in memory list
  else
     //await get data from the API
  </code></pre>
  
  <p>But the return type in the first part of the if statement is <code>List&lt;T&gt;</code> whereas the return type of the second part is <code>Task&lt;List&lt;T&gt;&gt;</code></p>
  
  <p>How can I do this? Can I just have my in-memory list be a Task? (Maybe I can wrap the List in a task)? </p>
  
  <p>Thank you all!</p>