Intermediate C#
Q57 / 100

What is the difference between ValueTask and Task?

Correct! Well done.

Incorrect.

The correct answer is B) ValueTask is a struct that avoids heap allocation when a result is available synchronously, unlike Task which always allocates

B

Correct Answer

ValueTask is a struct that avoids heap allocation when a result is available synchronously, unlike Task which always allocates

Explanation

ValueTask<T> avoids Task allocation when the operation completes synchronously (common in cache-hit paths). Task is safe to await multiple times; ValueTask is not.

Progress
57/100