I'm new to C#. I'm trying to get a List.Select
to work with async tasks, and I'm getting an error with the Select
call. The error says
The type arguments for method 'IEnumerable System.Linq.Enumerable.Select(this IEnumerable, Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Here's my code:
var lst = new List<string>();
lst.Add("");
lst.Add("");
var tasks = lst.Select(async x =>
{
await Task.Delay(1000);
throw new Exception();
});
await Task.WhenAll(tasks);