Reputation: 21
So i have a method
[HttpGet('api/xxx/xxxx/xxx')
public HttpResponseMessage DoMyWork<T>(T obj)
{
}
Is it possible to pass the type to the call? if so how?
Thank you
Upvotes: 2
Views: 78
Reputation: 7880
public async Task<T> DoMyWork<T>(T obj)
{
using(var client = new HttpClient())
{
var response = await client.GetAsync(uri);
return await response.Content.ReadAsAsync<T>();
}
}
It depends on what you're calling.
Upvotes: 1