【发布时间】:2011-01-07 10:27:38
【问题描述】:
我正在尝试从 Web 服务中获取信息,然后在整个项目中使用该信息,但无法弄清楚如何从 Web 服务查询中设置公共字符串。目前,我已将 id 硬编码到公共字符串中。如何将硬编码的值替换为查询返回的值?
public MainPage()
{
WebClient id = new WebClient();
id.Credentials = new NetworkCredential(UsernameSetting, PasswordSetting);
id.DownloadStringCompleted += new DownloadStringCompletedEventHandler(id_DownloadStringCompleted);
id.DownloadStringAsync(new Uri("https://web-service-address/"));
}
void id_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
XDocument xDocument = XDocument.Parse(e.Result);
var myid = xDocument.Descendants("service").First();
}
public string IDSetting = "1234567";
【问题讨论】:
标签: linq windows-phone-7