本文整理汇总了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) { }
}