Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<T>'.
Example
The following sample generates CS4032:
// CS4032.cs (7,9)
using System.Collections.Generic;
using System.Threading.Tasks;
class C
{
static IAsyncEnumerator<int> M(int value)
{
yield return value;
await Task.CompletedTask;
}
}
To correct this error
To correct this error, change the signature of method M
to make it asynchronous:
using System.Collections.Generic;
using System.Threading.Tasks;
class C
{
static async IAsyncEnumerator<int> M(int value)
{
yield return value;
await Task.CompletedTask;
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.