Closed mpostol closed 3 years ago
Thanks for writing this @mpostol This could be explained better.
The point is that await
can be either an expression or a statement, depending on its operand. When the operand is a Task
, await
is parsed as a statement: there is no result. When the operand is a Task<T>
, await
is parsed as an expression, and it's result is of type T
.
I've added this to our backlog to update.
@BillWagner I think @mpostol refers to declaration statement T result =...
. I think any expression may be at right
To make sure the C# Language Specification must be revisited and referred to. Sec. 1.4 and 1.5 provides a detailed description. Anyway if we have x=\<something> we have an assignment statement. The mentioned section numbers could change because I have noticed that my specification is very old and I cannot find a new one right now.
T result = await SomeTaskMethodAsync<T>();
looks like statement but not expression. `await SomeTaskMethodAsync()`` is rather an expression.Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.