Why does this async lambda function invocation not compile in C#?
问题 I seem to be missing something really basic in my understanding. I am trying to call an async function that will take a Func<T> passed in by the caller, in case if the async function doesn't find a value in the cache. I am really puzzled as to why my code won't compile. My calling code is as follows static void Main(string[] args) { Func<Task<string>> dataFetcher = async () => { string myCacheValue = await new HttpClient().GetStringAsync("http://stackoverflow.com/"); return myCacheValue; };