Xe货币转换器使用Asp.net问题 [英] Xe currency Convertor using Asp.net Problem

查看:98
本文介绍了Xe货币转换器使用Asp.net问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  private   double  GetConvertedCurrencyValue( string  inputCurrency, string  outputCurrency, double   value 
{
string request = String 。格式( http://www.xe.com/ucc/convert.cgi?Amount= {0}& From = {1}& To = {2} value ,inputCurrency,outputCurrency);

System.Net.WebClient wc = new System.Net.WebClient();
string apiResponse = wc.DownloadString(request); // 这是一个阻止操作。
wc.Dispose();

/ * 格式化* /
// 典型响应:XE.com:curr1到curr2率:x curr1 = y curr2
// 第一部分,直到x curr1基本上是常数


string header = String .Format( XE.com:{0}到{1}率:,inputCurrency,outputCurrency);

// 删除标题
// 现在响应如下:x curr1 = y curr2
apiResponse = apiResponse.Replace(header,< span class =code-string> );

// 让我们将响应拆分为'=',以检索正确的部分
string outValue = apiResponse.Split(' =')[ 1 ];

// 摆脱'curr2'部分
outValue = outValue.Replace(outputCurrency, );

return Double .Parse(outValue,System.Globalization.CultureInfo.InvariantCulture );
}









它给出了以下错误最后一行。请立即回复......





输入字符串的格式不正确。

解决方案

您好b $ b您是否检查  你得到了什么错误。我希望你得到错误消息喜欢这个:





返回Double.Parse(outValue,System.Globalization.CultureInfo.InvariantCulture);
来自outValue的
如果您检查将收到如下错误消息:

http://www.w3.org/1999/xhtml\">

< head>

<! - - 警告:使用条款禁止自动提取费率。 - >

http://www.xe.com/errors/noautoextract.htm[ ^ ]



chk此链接:



http:// stackoverflow .com / questions / 15105308 / how-to-programmatically-extract-information-from-a-web-page-using-linux-command [ ^ ]< / head>


private double GetConvertedCurrencyValue(string inputCurrency, string outputCurrency, double value)
   {
       string request = String.Format("http://www.xe.com/ucc/convert.cgi?Amount={0}&From={1}&To={2}", value, inputCurrency, outputCurrency);
 
       System.Net.WebClient wc = new System.Net.WebClient();
       string apiResponse = wc.DownloadString(request);    // This is a blocking operation.
       wc.Dispose();
 
       /* Formatting */
       // Typical response: "XE.com: curr1 to curr2 rate: x curr1 = y curr2"
       // The first part, up until "x curr1" is basically a constant

 
       string header = String.Format("XE.com: {0} to {1} rate:", inputCurrency, outputCurrency);
 
       // Removing the header
       // The response now looks like this: x curr1 = y curr2
       apiResponse = apiResponse.Replace(header, "");
 
       // Let's split the response at '=', to retrieve the right part
       string outValue = apiResponse.Split('=')[1];
 
       // Getting rid of the 'curr2' part
       outValue = outValue.Replace(outputCurrency, "");
 
       return Double.Parse(outValue, System.Globalization.CultureInfo.InvariantCulture);
   }





it gives an below error in last line .please reply immediately......


Input string was not in a correct format.

解决方案

Hi
Did you check with what error did you get .I hope you get the error message like this :



return Double.Parse(outValue, System.Globalization.CultureInfo.InvariantCulture);
from outValue if you check you will get the error message as below :
"http://www.w3.org/1999/xhtml">
<head>
<!-- WARNING: Automated extraction of rates is prohibited under the Terms of Use. -->
http://www.xe.com/errors/noautoextract.htm[^]

chk this link :

http://stackoverflow.com/questions/15105308/how-to-programmatically-extract-information-from-a-web-page-using-linux-command[^]</head>


这篇关于Xe货币转换器使用Asp.net问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆