The input string is not in the correct format error when using the conversion API in Google.

My application is in Asp.Net MVC3 encoded in C # .Net. I am using the Google Conversion API for conversion.

Google Currency Conversion API I pass the values From Currency and In Currency and the amount to my controller. Below is the 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 in the line

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

Error The input string is not in the correct format . Internal exception does not exist.

I tried converting to toString ()

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

I also tried to accept the match value in a string variable, and then try to execute the SubString logic on it. But it doesn’t work either

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

( "), ". , . .

+5
1

URL-.

    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);
0

All Articles