Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I declare a generic async Task?

Tags:

c#

generics

I have the following method:

public async Task<List<Product>> GetProductsAsync()

Which is fine, returns a list of Products.

However I'd like to make this generic - something like...

public async Task<List<T>> GetAsync()

But I'm struggling with syntax and I'd really appreciate it if someone can point me in the right direction.

Thanks

like image 893
Mark Chidlow Avatar asked Feb 07 '16 13:02

Mark Chidlow


1 Answers

Almost there:

public async Task<List<T>> GetAsync<T>()
like image 167
usr Avatar answered Sep 22 '22 19:09

usr