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);
Im getting an error on line
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.
I tried it to convert to toString()
decimal rate = Convert.ToDecimal(match.Groups[1].Value.ToString());
Also i tried to take the value of match in a string variable and then try doing a SubString logic on it.But its not working either
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.
Try this for getting url.