当前位置: 首页>>代码示例>>C#>>正文


C# XmlTextReader.ReadElementContentAsDecimal方法代码示例

本文整理汇总了C#中XmlTextReader.ReadElementContentAsDecimal方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader.ReadElementContentAsDecimal方法的具体用法?C# XmlTextReader.ReadElementContentAsDecimal怎么用?C# XmlTextReader.ReadElementContentAsDecimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlTextReader的用法示例。


在下文中一共展示了XmlTextReader.ReadElementContentAsDecimal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WindButton_Click

    protected void WindButton_Click(object sender, EventArgs e)
    {
        // find wind speed
        try
        {
            WindService.Service1Client myClient = new WindService.Service1Client();
            decimal windSp = myClient.WindIntensity(Convert.ToDecimal(latTextBox.Text), Convert.ToDecimal(longTextBox.Text)); // calls service
            if (knotsRadio.Checked == true)
                speedLabel.Text = windSp.ToString("N3") + " knots";  // outputs results in knots
            else
                speedLabel.Text = JbClass.convertToMph(Convert.ToDouble(windSp)).ToString("N3") + " mph";  // converts from knots to mph

            myClient.Close();
        }
        catch (InvalidCastException) { }
        catch (FormatException) // if both fields aren't selected
        {
            speedLabel.Text = "Please enter both fields";
        }
        catch (Exception) { }

        // find elevation
        try
        {
            decimal lat = Convert.ToDecimal(latTextBox.Text);
            decimal longi = Convert.ToDecimal(longTextBox.Text);

            int inum = Session.Count + 1;
            if (inum >= 6)
            {
                string place2 = (string)Session["place2"];
                string place3 = (string)Session["place3"];
                string place4 = (string)Session["place4"];
                string place5 = (string)Session["place5"];
                Session["place1"] = place2;
                Session["place2"] = place3;
                Session["place3"] = place4;
                Session["place4"] = place5;
                Session["place5"] = latTextBox.Text + ", " + longTextBox.Text;
            }
            else
            {
                string num = Convert.ToString(inum);
                string catalogKey = "place" + num;
                Session[catalogKey] = latTextBox.Text + ", " + longTextBox.Text;
            }

            string url = string.Format("http://webstrar31.fulton.asu.edu/page0/page00/service1.svc/elev?latitude={0}&longitude={1}", lat, longi);

            // create http request from string URL
            HttpWebRequest elevRequest = (HttpWebRequest)WebRequest.Create(url);

            // send webrequest and wait for response
            HttpWebResponse elevResponse = (HttpWebResponse)elevRequest.GetResponse();

            // get stream associated with response
            Stream elevReceiver = elevResponse.GetResponseStream();

            // copy the data from XML format into a string
            XmlTextReader reader = new XmlTextReader(elevReceiver);
            reader.ReadToFollowing("decimal");
            decimal elevation = reader.ReadElementContentAsDecimal();

            if (feetRadio.Checked == true)
                elevationLabel.Text = elevation.ToString("N2") + " feet above sea level";
            else
                elevationLabel.Text = JbClass.convertToMeters(Convert.ToDouble(elevation)).ToString("N2") + " meters above sea level";
        }
        catch (FormatException) { elevationLabel.Text = "Please enter both fields"; }
        catch (Exception) { }
    }
开发者ID:jjipson,项目名称:assignment5,代码行数:71,代码来源:Page2.aspx.cs


注:本文中的XmlTextReader.ReadElementContentAsDecimal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。