コンパイラ エラー CS8411

型 "type" は "GetAsyncEnumerator" の適切なパブリック インスタンス定義を含んでいないため、"type" の変数に対して非同期 foreach ステートメントを使用することはできません

await foreach ステートメントは、IAsyncEnumerable<T> など、GetAsyncEnumerator の定義が与えられている型のみで動作します。

このエラーを解決するには

await foreachforeach で置き換え

using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
    async Task Example(IAsyncEnumerator<int> enumerator)
    {
        // error CS8411: Asynchronous foreach statement cannot operate on variables
        // of type 'IAsyncEnumerator<T>' because 'IAsyncEnumerator<T>' does not
        // contain a suitable public instance definition for 'GetAsyncEnumerator'
        await foreach (int i in enumerator)
        {
        }
    }
}