Xamarin Erro CS0161 GetResponse <t>(字符串,字符串,字符串)':并非所有代码路径都返回一个值

时间:2016-05-20 20:01:53

标签: c# xamarin

我有这个代码,但是我收到了一个错误:错误CS0161'ApiCall.GetResponse(string,string,string)':并非所有代码路径都返回值

public class ApiCall
{
    static readonly string ApiUrl = "http://localhost:1762/api/{0}/{1}?{2}";

    public async Task<T> GetResponse<T>(string controller, string method, string prm) where T : class
    {

        var client = new System.Net.Http.HttpClient();


        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


        var response = await client.GetAsync(string.Format(ApiUrl, controller, method, prm));
        var JsonResult = response.Content.ReadAsStringAsync().Result;

        if (typeof(T) == typeof(string))
            return null;

        var rootobject = JsonConvert.DeserializeObject<T>(JsonResult);
            return rootobject;
   }
 }
}

有人知道吗?

0 个答案:

没有答案