Answer the question
In order to leave comments, you need to log in
How to return a generic value?
How to return generic value?
I can't understand why I can't return return TResponse in the GetAsync method? How to get it back...?
public Task<TResponse> GetAsync<TResponse>(RequestParameters parameters)
{
AddAuthorizationHeader(parameters);
return TResponse;
}
public override Task<HttpResponseMessage> GetAsync(RequestParameters parameters)
{
AddAuthorizationHeader(parameters);
return base.GetAsync(parameters);
}
private RequestParameters AddAuthorizationHeader(RequestParameters parameters)
{
parameters.Headers = new Dictionary<string, IEnumerable<string>>
{ { "Authorization", new[] { credentials.Token } } };
return parameters;
}
Answer the question
In order to leave comments, you need to log in
Because TResponse is a type, but you need to return a value of type Task<TResponse>
.
This TResponse must be obtained from somewhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question