Syntax

C# Async / Await Syntax

In C#, async / await: waits for a task without blocking — var text = await File.ReadAllTextAsync("a.txt");

Quick Answer

Syntax
var text = await File.ReadAllTextAsync("a.txt");
C#Syntax

Async / Await

Code example
var text = await File.ReadAllTextAsync("a.txt");

Waits for a task without blocking.

Learn More

How to async / await in C#

  1. Open your C# file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C# Async / Await Syntax

Use var text = await File.ReadAllTextAsync("a.txt");.

Related Syntax References

Frequently asked questions

What is the C# syntax for async / await?

Use this pattern: var text = await File.ReadAllTextAsync("a.txt");

Can I copy this C# code example?

Yes. Use Copy code and adapt the example to your program.

Is this C# syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify