English 中文(简体)
在使用谷歌货币换算标语时,显示不出现校正格式错误的产出
原标题:Input string not in Correct format error while using the Google currency Conversion API

My application is in Asp.Net MVC3 coded in C#.Net. Im using google Currency Conversion API for getting the conversion.

Google Currency Conversion API Im passing the From Currency and To Currency values and the amount to my Controller. Below is my C# code.

    WebClient web = new WebClient();
    string url = string.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", CurrenctCurr.ToUpper(), DestinationCurr.ToUpper(), TotCurrentPay);
    string response = web.DownloadString(url);
    Regex regex = new Regex("rhs: \"(\d*.\d*)");
    Match match = regex.Match(response);
    decimal rate = Convert.ToDecimal(match.Groups[1].Value);

错线

decimal rate = Convert.ToDecimal(match.Groups[1].Value.ToString());

The error is Input string not in Correct format.There is no inner exception to it.

我试图将其改为稳定。

   decimal rate = Convert.ToDecimal(match.Groups[1].Value.ToString());

同时,我试图将match的数值乘以微薄的变量,然后尝试对其采取分层逻辑。 但它没有工作

string test = match.ToString();
test=test.substring(0,test.Indexof("""));

There is a single Quotation ("),so im trying to take the value of string till ". Suggest how can i solve the issue.Or what else can i try in the right direction.

最佳回答

引诱.。

    Uri uri = new Uri(string.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", CurrenctCurr.ToUpper(), DestinationCurr.ToUpper(), TotCurrentPay));
    string url = uri.AbsoluteUri + uri.Fragment;
    string response = web.DownloadString(url);
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签