【问题标题】:WP7 Set public string value from web service queryWP7 从 Web 服务查询中设置公共字符串值
【发布时间】: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


    【解决方案1】:

    可以在id_DownloadStringCompleted()的最后将myid的值赋给IDSetting

    IDSetting = myid;
    

    【讨论】:

      猜你喜欢
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多