Back to results for “Asynchronous Programming”
C# › Asynchronous Programming

What is the difference between Task and Task<T>?

Beginner

Answer

Task represents async work with no result; Task<T> completes with a value of type T that you get by awaiting it.
Task done = Task.Delay(100);
Task<int> n = Task.FromResult(42);
int v = await n;
Real-world example Returning Task<Order> from a repository so callers can await the fetched order.