我想從一個通用的Windows Phone應用程序一個JSON文件來分析,但我不能轉換任務字符串轉換任務<string>串
public MainPage()
{
this.InitializeComponent();
HttpClient httpClient = new HttpClient();
String responseLine;
JObject o;
try
{
string responseBodyAsText;
HttpResponseMessage response = httpClient.GetAsync("http://localhost/list.php").Result;
//response = await client.PostAsync(url, new FormUrlEncodedContent(values));
response.EnsureSuccessStatusCode();
responseBodyAsText = response.Content.ReadAsStringAsync().Result;
// responseLine = responseBodyAsText;
string Website = "http://localhost/list.php";
Task<string> datatask = httpClient.GetStringAsync(new Uri(string.Format(Website, DateTime.UtcNow.Ticks)));
string data = await datatask;
o = JObject.Parse(data);
Debug.WriteLine("firstname:" + o["id"][0]);
}
catch (HttpRequestException hre)
{
}
我有錯誤在這行
string data = await datatask;
我該如何解決它?
'string data = datatask.Result;'工作嗎? – Enigmativity