Practice mode C#

If an async method is declared as async Task GetCountAsync(), what type does await GetCountAsync() produce?

Correct answer A. int

Explanation

Awaiting a Task unwraps it, so the expression await GetCountAsync() has type int once the task completes. Inside the method, you write return 5; and the compiler wraps the value in the task. If the task faults, await rethrows the original exception. A plain Task represents an operation with no result, so awaiting it produces no value.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.