0

How to use yield return when method's return-type is a Task, for example Task<IEnumerable<string>>?

This is my code:

    private async Task<IEnumerable<string>> GetNameAsync(List<MyEntity> entities)
    {
        List<string> finalstrings = new List<string>();

        foreach (var item in entities)
        {
            finalstrings.Add(item.Name);
        }

        return finalstrings;
    }

I'm using dotnet core 3.1.

Thanks in advance.

Peter B
  • 21,067
  • 5
  • 28
  • 63
Mehrdad
  • 1,323
  • 7
  • 21

0 Answers0