-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Open
Description
Type of issue
Typo
Description
Hi,
The function ToastBreadAsync is missing closing brace "}" marking the end of the block.
// Non-async, task-returning method.
// Within this method (but outside of the local function),
// any thrown exceptions emerge synchronously.
public static Task ToastBreadAsync(int slices, int toastTime)
{
if (slices is < 1 or > 4)
{
throw new ArgumentException(
"You must specify between 1 and 4 slices of bread.",
nameof(slices));
}
if (toastTime < 1)
{
throw new ArgumentException(
"Toast time is too short.", nameof(toastTime));
}
return ToastBreadAsyncCore(slices, toastTime);
} <<<<<<<< Here
// Local async function.
// Within this function, any thrown exceptions are stored in the task.
static async Task<Toast> ToastBreadAsyncCore(int slices, int time)
{
for (int slice = 0; slice < slices; slice++)
{
Console.WriteLine("Putting a slice of bread in the toaster");
}
// Start toasting.
await Task.Delay(time);
if (time > 2_000)
{
throw new InvalidOperationException("The toaster is on fire!");
}
Console.WriteLine("Toast is ready!");
return new Toast();
}
} <<< Incorrect.
Page URL
Content source URL
Document Version Independent Id
4d98bec1-a03a-4a9c-4108-cb847f9c18bd
Platform Id
4476e67a-3bdf-33df-dc3a-38e385729bc9
Article author
Metadata
- ID: cfeeac2f-fbeb-b4b5-ff02-fd48a28a2768
- PlatformId: 4476e67a-3bdf-33df-dc3a-38e385729bc9
- Service: dotnet-csharp
- Sub-service: fundamentals